regression {RGeostats}  R Documentation 
Linear Regression
regression(db, name1=db.getname(db,"z",1), names=NA, db2=NA, uc=c("1"), flag.mode=0, flag.one=TRUE, verbose = 0, save.coeff = FALSE, flag.draw=FALSE, ...)
db 
The 
name1 
Rank of the target variable in the Db for which a linear multivariate regression must be established. 
names 
List of names of attributes that are used as explanatory variables.
For more information see 
db2 
If 'db2' is specified, the explanatory variables are read from this Db. This Db2 must have exactly the same organization as 'Db'. If not defined, 'db2' is replaced by 'db1'. 
uc 
The drift description. Use command 
flag.mode 

flag.one 
When TRUE, the constant is considered as an additional explanatory variable. This only makes sense for flag.mode equal to 0 or 1; in the case of flag.mode==2, the constant may be directly specified in the 'uc' argument. 
verbose 

save.coeff 
Defines the output option:

flag.draw 
When TRUE (and if flag.ext is 0 and a graphic already exists), the regression line is overlaid on the current figure. 
... 
Parameters passed to the function 
The returned value depends upon the argument save.coeff.
# Load the information from the Scotland 2D Data Set (renamed as db) # The Db contains 236 samples with variables "Elevation" and "January_temp". data(Exdemo_Scotland_Temperatures) db = Exdemo_Scotland_Temperatures ########################### # flag.mode = 0 (default) # ########################### # Perform the linear regression of the variable (y) 'Elevation' as a # function of explanatory variable (x) 'January_temp' with a constant regression(db,"Elevation","January_temp",flag.one=TRUE,save.coeff=TRUE) # The resulting equation is: y = 287.87 * x  71.022 # Perform the same regression with no ordinate at the origin regression(db,"Elevation","January_temp",flag.one=FALSE,save.coeff=TRUE) # The resulting equation is: y = 19.59 * x ################# # flag.mode = 1 # ################# # We consider the variable "January_temp" as an external drift db = db.locate(db,"January_temp","f") # Perform the regression of the first data variable (locator "z1") # as a function of the external drift(s) regression(db,flag.mode=1,save.coeff=TRUE) # The resulting equation is (again): y = 287.87 * x  71.022 ################# # flag.mode = 2 # ################# # We use the standard drift definition in the regression regression(db,flag.mode=2,uc=c("1","f1"),save.coeff=TRUE) # The resulting equation is (again): y = 287.87 * x  71.022 # In order to suppress the ordinate at the origin, we must run: regression(db,flag.mode=2,uc=c("f1"),save.coeff=TRUE) # The resulting equation is (again): y = 19.59 * x # The next test is to perform the regression of the main variable as a # function of a complex drift composed of a constant, the external # drift, the first order coordinates regression(db,flag.mode=2,uc=c("1","f1","x","y"),save.coeff=TRUE) # The resulting equation is: # y = 401.69  77.84 * f1  0.2178 * x1  0.0425 * x2