#To get the 95% CI of beta1_sq and beta2_sq
#beta1 and beta2 are regression coefficients from a multiple regression model,
#i.e. y = x1 * beta1 + x2 * beta2 +e, where y, x1 and x2 are column-standardised.
dat=dat2
nv=length(dat$V1)
v1=c(1)
v2=c(2)
output=r2_beta_var(dat,v1,v2,nv)
output
#r2redux output
#output$beta1_sq (beta1_sq)
#0.01118301
#output$beta2_sq (beta2_sq)
#0.004980285
#output$var1 (variance of beta1_sq)
#7.072931e-05
#output$var2 (variance of beta2_sq)
#3.161929e-05
#output$var1_2 (variance of difference between beta1_sq and beta2_sq)
#0.000162113
#output$cov (covariance between beta1_sq and beta2_sq)
#-2.988221e-05
#output$upper_beta1_sq (upper limit of 95% CI for beta1_sq)
#0.03037793
#output$lower_beta1_sq (lower limit of 95% CI for beta1_sq)
#-0.00123582
#output$upper_beta2_sq (upper limit of 95% CI for beta2_sq)
#0.02490076
#output$lower_beta2_sq (lower limit of 95% CI for beta2_sq)
#-0.005127546
Run the code above in your browser using DataLab