mlm

Obtain standard errors of regression coefficients for an “mlm” object returned by `lm()`

倾然丶 夕夏残阳落幕 提交于 2019-11-28 08:28:21
问题 I'd like to run 10 regressions against the same regressor, then pull all the standard errors without using a loop . depVars <- as.matrix(data[,1:10]) # multiple dependent variables regressor <- as.matrix([,11]) # independent variable allModels <- lm(depVars ~ regressor) # multiple, single variable regressions summary(allModels)[1] # Can "view" the standard error for 1st regression, but can't extract... allModels is stored as an "mlm" object, which is really tough to work with. It'd be great

Fitting a linear model with multiple LHS

送分小仙女□ 提交于 2019-11-25 23:50:04
问题 I am new to R and I want to improve the following script with an *apply function (I have read about apply , but I couldn\'t manage to use it). I want to use lm function on multiple independent variables (which are columns in a data frame). I used for (i in (1:3) { assign(paste0(\'lm.\',names(data[i])), lm(formula=formula(i),data=data)) } Formula(i) is defined as formula=function(x) { as.formula ( paste(names(data[x]),\'~\', paste0(names(data[-1:-3]), collapse = \'+\')), env=parent.frame() ) }