Displaying 1 result from an estimated 1 matches for "weightsvector".
2010 Oct 22
1
lm looking for weights outside of the user-defined function
...ights
outside of my function's environment:
### Generating example data:
x<-data.frame(y=rnorm(100,0,1),a=rnorm(100,1,1),b=rnorm(100,2,1))
myweights<-runif(100)
data.for.regression<-x[1:3]
### Creating function "weighted.reg":
weighted.reg=function(formula, MyData, filename,WeightsVector)
{
print(dim(MyData))
print(filename)
print(length(WeightsVector))
regr.f<-lm(formula,MyData,weights=WeightsVector,na.action=na.omit)
results<-as.data.frame(round(summary(regr.f)$coeff,3))
write.csv(results,file=filename)
return(results)
}
### Running "weighted.reg" with my...