Hi, r-users I got a problem when I try to call a *gls* function in loop structure. The gls function seems not able to recognize the parameters that I pass into the loop function! (But, if I use lm function, it works.) The code looks like this: ================================================gls.lm <- function(Data, iv1, dv1) { gls.model <- gls(Data[ , dv1] ~ Data[ , iv1], correlation = corARMA(p=1), method='ML',na.action=na.omit, data = Data) print(summary(gls.model)) } regResultMatrix <- gls.lm(DR, 'Period', 'Aircraft') regResultMatrix <- gls.lm(DR, 'Period', 'Total.Employees') =================================================The "DR" is the data in excel file which includes three columns: Period, Aircraft and Total.Employees. And, I got the error message like this: *Error in eval(expr, envir, enclos) : object 'dv1' not found* Could any one tell me what is going on there? Thanks in advance. Miles -- ------------------ Miles Yang Mobile:+61-411-985-538 E-mail:miles2yang@gmail.com ------------------ [[alternative HTML version deleted]]