mlm

Get confidence intervals for regression coefficients of “mlm” object returned by `lm()`

限于喜欢 提交于 2020-08-25 04:25:26
问题 I'm running a multivariate regression with 2 outcome variables and 5 predictors. I would like to obtain the confidence intervals for all regression coefficients. Usually I use the function lm but it doesn't seem to work for a multivariate regression model (object mlm ). Here's a reproducible example. library(car) mod <- lm(cbind(income, prestige) ~ education + women, data=Prestige) confint(mod) # doesn't return anything. Any alternative way to do it? (I could just use the value of the

Fit many linear models in R with identical design matrices [duplicate]

笑着哭i 提交于 2020-01-04 15:58:11
问题 This question already has an answer here : Fitting a linear model with multiple LHS (1 answer) Closed 3 years ago . For a neuroimaging application, I'm trying to fit many linear models by least squares in R (standard call to lm ). Imagine I have a design matrix X. This design matrix will be the same across all of the models. The data (Y) that is being fit will change, and as a result so will all of the fit parameters (e.g. betas, p-values, residuals, etc). At present, I'm just sticking it in

Fit many linear models in R with identical design matrices [duplicate]

二次信任 提交于 2020-01-04 15:57:08
问题 This question already has an answer here : Fitting a linear model with multiple LHS (1 answer) Closed 3 years ago . For a neuroimaging application, I'm trying to fit many linear models by least squares in R (standard call to lm ). Imagine I have a design matrix X. This design matrix will be the same across all of the models. The data (Y) that is being fit will change, and as a result so will all of the fit parameters (e.g. betas, p-values, residuals, etc). At present, I'm just sticking it in

Run lm with multiple responses and weights

眉间皱痕 提交于 2019-12-11 07:39:02
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I have to fit a linear model with the same model matrix to multiple responses. This can be easily done in R by specifying the response as matrix instead of a vector. Computation is very fast in this way. Now I would also like to add weights to the model that correspond to the accuracy of responses. Therefore, for each response vector I would need also different weight vector.

rstudent() returns incorrect result for an “mlm” (linear models fitted with multiple LHS)

巧了我就是萌 提交于 2019-12-11 03:19:30
问题 I know that the support for linear models with multiple LHS is limited. But when it is possible to run a function on an "mlm" object, I would expect the results to be trusty. When using rstudent , strange results are produced. Is this a bug or is there some other explanation? In the example below fittedA and fittedB are identical, but in the case of rstudent the 2nd column differs. y <- matrix(rnorm(20), 10, 2) x <- 1:10 fittedA <- fitted(lm(y ~ x)) fittedB <- cbind(fitted(lm(y[, 1] ~ x)),

Applying lm() and predict() to multiple columns in a data frame

倾然丶 夕夏残阳落幕 提交于 2019-12-06 09:08:05
问题 I have an example dataset below. train<-data.frame(x1 = c(4,5,6,4,3,5), x2 = c(4,2,4,0,5,4), x3 = c(1,1,1,0,0,1), x4 = c(1,0,1,1,0,0), x5 = c(0,0,0,1,1,1)) Suppose I want to create separate models for column x3 , x4 , x5 based on column x1 and x2 . For example lm1 <- lm(x3 ~ x1 + x2) lm2 <- lm(x4 ~ x1 + x2) lm3 <- lm(x5 ~ x1 + x2) I want to then take these models and apply them to a testing set using predict, and then create a matrix that has each model outcome as a column. test <- data.frame

Applying lm() and predict() to multiple columns in a data frame

淺唱寂寞╮ 提交于 2019-12-04 17:26:19
I have an example dataset below. train<-data.frame(x1 = c(4,5,6,4,3,5), x2 = c(4,2,4,0,5,4), x3 = c(1,1,1,0,0,1), x4 = c(1,0,1,1,0,0), x5 = c(0,0,0,1,1,1)) Suppose I want to create separate models for column x3 , x4 , x5 based on column x1 and x2 . For example lm1 <- lm(x3 ~ x1 + x2) lm2 <- lm(x4 ~ x1 + x2) lm3 <- lm(x5 ~ x1 + x2) I want to then take these models and apply them to a testing set using predict, and then create a matrix that has each model outcome as a column. test <- data.frame(x1 = c(4,3,2,1,5,6), x2 = c(4,2,1,6,8,5)) p1 <- predict(lm1, newdata = test) p2 <- predict(lm2,

Prediction of 'mlm' linear model object from `lm()`

穿精又带淫゛_ 提交于 2019-11-30 09:37:20
问题 I have three datasets: response - matrix of 5(samples) x 10(dependent variables) predictors - matrix of 5(samples) x 2(independent variables) test_set - matrix of 10(samples) x 10(dependent variables defined in response) response <- matrix(sample.int(15, size = 5*10, replace = TRUE), nrow = 5, ncol = 10) colnames(response) <- c("1_DV","2_DV","3_DV","4_DV","5_DV","6_DV","7_DV","8_DV","9_DV","10_DV") predictors <- matrix(sample.int(15, size = 7*2, replace = TRUE), nrow = 5, ncol = 2) colnames

Prediction of 'mlm' linear model object from `lm()`

[亡魂溺海] 提交于 2019-11-29 16:15:11
I have three datasets: response - matrix of 5(samples) x 10(dependent variables) predictors - matrix of 5(samples) x 2(independent variables) test_set - matrix of 10(samples) x 10(dependent variables defined in response) response <- matrix(sample.int(15, size = 5*10, replace = TRUE), nrow = 5, ncol = 10) colnames(response) <- c("1_DV","2_DV","3_DV","4_DV","5_DV","6_DV","7_DV","8_DV","9_DV","10_DV") predictors <- matrix(sample.int(15, size = 7*2, replace = TRUE), nrow = 5, ncol = 2) colnames(predictors) <- c("1_IV","2_IV") test_set <- matrix(sample.int(15, size = 10*2, replace = TRUE), nrow =

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

萝らか妹 提交于 2019-11-29 14:50:12
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 if I could store a list of lm objects or a matrix with statistics of interest. Again, the objective is