I'm very new to R, I want to run a specific function (ideal from the pscl package) for 50 different data (roll call class) that have a suffix from 1 to 50, and I want to save the results in objects also with a 1 to 50 suffix, but I can not do it.
The apply does not work, since I need to specify additional paramaters in the ideal function, and I already tried creating a new function that sets the additional parameters and permits to specify the function only with the data, but it fails in the second step (does not recognize the object).
I have the data objects for my function: rc.1, rc.2, ..., rc.50 And try to do the following - following closely how I would do it in Stata...
for (i in 1:3) {
est.leg[i]<-ideal(rc[i], maxiter=1000, burnin=500, thin=10, normalize=TRUE)
}
And it does not evaluate in rc[i], says "object 'rc' not found"
I have also tried:
loop.ideal<- function(zz){
ideal(zz, d=1, maxiter=100, burnin=50, thin=10, normalize=TRUE)
}
but when testing the function, it does not work with the iterations.
I would really appreciate any help!!!!