RBaskin@ahrq.gov
2003-Oct-30 19:49 UTC
[R] Variance of a non-linear combination of the coefficient e stiamtes
< In Stata, I can just use "bs" function ...> in STATA the bs command runs a bootstrap If you want to use the bootstrap function (or you could linearize b*c/a :) look under ?boot (you may need to load the package first). Usage: boot(data, statistic, R, sim="ordinary", stype="i", strata=rep(1,n), L=NULL, m=0, weights=NULL, ran.gen=function(d, p) d, mle=NULL, ...) I tried to provide an example - others can clean up the R code for me:> test.df<-cbind(rnorm(25),rnorm(25),rnorm(25)) > test.model<-lm(test.df[,1]~test.df[,2]+test.df[,3]) > summary(test.model)Call: lm(formula = test.df[, 1] ~ test.df[, 2] + test.df[, 3]) Residuals: Min 1Q Median 3Q Max -1.3784 -0.6903 -0.2278 0.5879 2.7298 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.03419 0.20907 -0.164 0.872 test.df[, 2] -0.29636 0.17705 -1.674 0.108 test.df[, 3] 0.16059 0.21060 0.763 0.454 Residual standard error: 1.018 on 22 degrees of freedom Multiple R-Squared: 0.1439, Adjusted R-squared: 0.06613 F-statistic: 1.85 on 2 and 22 DF, p-value: 0.1809>test.model$coefficients[2]*test.model$coefficients[3]/test.model$coefficient s[1] test.df[, 2] 1.391884> umeno.stat<-function(xx,...){+ xx.model<-lm(xx[...,1]~xx[...,2]+xx[...,3]) + xx.model$coefficient[2]*xx.model$coefficient[3]/xx.model$coefficient[1]}> umeno.stat(test.df,c(1:25))xx[..., 2] 1.391884> boot(test.df,umeno.stat,100)ORDINARY NONPARAMETRIC BOOTSTRAP Call: boot(data = test.df, statistic = umeno.stat, R = 100) Bootstrap Statistics : original bias std. error t1* 1.391884 0.2708119 16.32276>bob -----Original Message----- From: umeno [mailto:umeno@students.uiuc.edu] Sent: Thursday, October 30, 2003 1:19 PM To: R-Help <r-help Subject: [R] Variance of a non-linear combination of the coefficient estiamtes Hi, I would like to know if anyone knows how to compute a variance of the non-linear combination of the coefficient estimates. Say, I get a model of y~c+ax+bz (1) where x and z are the independent variables, c is the constant estimate, and a and b are the coefficient estimates. Then, I want to know the variance of b*c/a (2). How am I going to get it? In Stata, I can just use "bs" function by defining the regression model (1) and the statistic of the interest(2). Help!!! Thank you Soyoko ______________________________________ Ms. Soyoko Umeno Graduate Research Assitant for the Illinois-Missouri Biotechnology Alliance (IMBA) at http://www.imba.missouri.edu/ Ph.D. Student at the Department of Agricultural and Consumer Economics at the University of Illinois at Urbana-Champaign Office Phone: 217-333-3417 or 217-333-0364 Fax: 217-244-4817 Mailing Address: 1301 W. Gregory Dr. MC710, Urbana, IL 61801 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help [[alternative HTML version deleted]]