Hi, I have problem getting the standard deviation from the manova output. I have used the manova function: myfit <- manova(cbind(y1, y2) ~ x1 + x2 + x3, data=mydata) . I tried to get the predicted values and their standard deviation by using: predict(myfit, type="response", se.fit=TRUE) But the problem is that I don't get the standard deviation values, I only get the predicted values for y1 and y2. But if I type: predict*.lm*(myfit, type="response", se.fit=TRUE) I get the predicted values and standard deviation, but only for y1 (and nothing from y2...). //BF -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-from-MANOVA-tp4641322.html Sent from the R help mailing list archive at Nabble.com.
Standard deviation from MANOVA??
6 messages · BrutishFruit, Jean V Adams, David Winsemius +1 more
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120827/cafc2bea/attachment.pl>
On Aug 27, 2012, at 6:37 AM, Jean V Adams wrote:
Not sure why that is. You can always use manova() to get the multivariate summary statistics and then use individual models to get predictions for each response. For example, mydata <- data.frame(y1=rnorm(50), y2=rnorm(50), x1=rnorm(50), x2=rnorm(50), x3=rnorm(50)) myfit <- manova(cbind(y1, y2) ~ x1 + x2 + x3, data=mydata) summary(myfit) myfit1 <- lm(y1 ~ x1 + x2 + x3, data=mydata) myfit2 <- lm(y1 ~ x1 + x2 + x3, data=mydata)
I'm guessing this was supposed to be: myfit2 <- lm(y2 ~ x1 + x2 + x3, data=mydata)
predict(myfit1, se.fit=TRUE) predict(myfit2, se.fit=TRUE)
I suppose it is possible that what was desired were the standard errors around the fitted mean estimates (which I think is what this would deliver), but what was asked were for "standard deviations". I admit to being puzzled that `manova` was being thought of as a method, since the sample or population standard deviations should be derived from three applications of `tapply`. I think BruitishFruit should tell us what he means by "... don't get the standard deviation values" in sufficient detail that we get an unambiguous description what "standard deviations" are being requested. (Or he can pose a small test case with the "correct answer".)
Jean BrutishFruit <brutishfruit at hotmail.com> wrote on 08/25/2012 04:09:04 PM:
Hi, I have problem getting the standard deviation from the manova output. I have used the manova function: myfit <- manova(cbind(y1, y2)
~ x1
+ x2 + x3, data=mydata) . I tried to get the predicted values and their standard deviation by using: predict(myfit, type="response", se.fit=TRUE) But the problem is that I don't get the standard deviation values, I
only
get the predicted values for y1 and y2. But if I type: predict*.lm*(myfit, type="response", se.fit=TRUE) I get the predicted values and standard deviation, but only for y1 (and nothing from y2...). //BF
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi David. I mean that I want to get the *standard error of the predicted means* (which is a type standard deviation, if I have understand everything right), which the se.fit switch mentioned above should require from the "predict()" function. But the se.fit switch doesn't seem to work for manova object for some reason, which is my problem. Thanks for a suggestion of solution Jean. But i don't think that the standard error for the individual models will be the same as for the manova model. -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-from-MANOVA-tp4641322p4641441.html Sent from the R help mailing list archive at Nabble.com.
On Aug 27, 2012, at 19:15 , BrutishFruit wrote:
Hi David. I mean that I want to get the *standard error of the predicted means* (which is a type standard deviation, if I have understand everything right), which the se.fit switch mentioned above should require from the "predict()" function. But the se.fit switch doesn't seem to work for manova object for some reason, which is my problem. Thanks for a suggestion of solution Jean. But i don't think that the standard error for the individual models will be the same as for the manova model.
I suspect that they actually are the same, at least until you start messing with patterned covariance matrices or different models for different responses. Check the theory, though!
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Thanks for all help so far! And I seems as you are correct Peter (and Jean too). And I have now investigated and found how it is connected with the standard errors: If use the following code (taking from Jeans example code), where we have one manova and two individual models (continue read comments in code): # ------- code starts -------- # mydata <- data.frame(y1=rnorm(50), y2=rnorm(50), x1=rnorm(50), x2=rnorm(50), x3=rnorm(50)) myfit <- manova(cbind(y1, y2) ~ x1 + x2 + x3, data=mydata) myfit1 <- lm(y1 ~ x1 + x2 + x3, data=mydata) myfit2 <- lm(y2 ~ x1 + x2 + x3, data=mydata) # And then gets the standard error for each of the three models: stderr <- predict.lm(myfit, type="response", se.fit=TRUE)[[2]] stderr1 <- predict.lm(myfit1, type="response", se.fit=TRUE)[[2]] stderr2 <- predict.lm(myfit2, type="response", se.fit=TRUE)[[2]] # Will we get that stderr = sqrt(stderr1^2+stderr2^2) print(cbind(stderr,sqrt(stderr1^2 + stderr2^2))) # ------- code ends -------- # So, the reason why the output only gave one standard error when I was writing: ?But if I type: predict.lm(myfit, type="response", se.fit=TRUE) I get the predicted values and standard deviation, but only for y1 (and nothing from y2...). ? was because the output gave the combined error for both y1 and y2 by using the following formula: sqrt(stderr1^2 + stderr2^2). So it wasn't standard error for just y1 as I thought. You can test the provided code above and see that relationship is as described. So then my problem is solved as I can get the individual standard error for y1 and y2. Even if I don?t understand how you could/should use the combined standard error you get from the manova model (myfit)? //BF Mattias Siljestam Uppsala University -- View this message in context: http://r.789695.n4.nabble.com/Standard-deviation-from-MANOVA-tp4641322p4641622.html Sent from the R help mailing list archive at Nabble.com.