All --

I have been trying to work with the 'Party' package using R v2.15.1 and have cobbled together a (somewhat) functioning code from examples on the web.  I need to run a series of unbiased, conditional, cForest tests on several subsets of data which I have made into a loop.  The results ideally will be saved to an output file in matrix form.  The two questions regarding the script in question (script below) include:

1). After the cForest prints the initial results the error below is displayed:

"         Random Forest using Conditional Inference Trees
Number of trees:  500
Response:  Light
Inputs:  FormH, FormV, Uratio, Void, Transmis
Number of observations:  660
      FormH       FormV      Uratio        Void    Transmis
 2259311332   713202692  4250413991 50551193145   571666638
Error in print.default(occupied$Fan, predicted) :
  invalid 'digits' argument"

This error only occurs when I change the dependent variable name from " Fan " (the variable I used to develop and test the script with) to any of the other dependent variables I need to test.  All variables being tested are either continuous or categorical.  Could anyone provide me with more information about this error and possibly the source in the coding?

2). The results are saving successfully to a file as a list however, I wish to save the data into a matrix that resembles:

                         Subset 1,  Subset 2,  Subset n,
Var Importance:    VI.1             VI.2        VI.n
mse:                   mse.1         mse.2       mse.n
rsq:                    rsq.1            rsq.2        rsq.n
IV-1:                    x.1              x.2           x.n
IV-2:                    y.1              y.2           y.n
IV-n:                    n.1              a.2           n.n

How could I create output that would append/write sequential results as a new column in the file as opposed to being in list form?

Your comments are appreciated

-- Jay


Script in question:

> library(party)
> rm(list=ls())
> Dynamic <- read.csv(file="Dynamic_DATA.csv")
> set.seed(1851)
> ctrl <- cforest_unbiased(ntree=500, mtry=5)
>
> for (i in 1:4){ ## Climate subset
+ occupied <- subset(Dynamic, WDOccupancy == 1 & Climate == i, select = c(DataSet:DGI))
+ Dynamic.cf <- cforest(Fan ~ FormH + FormV + Uratio + Void + Transmis, data = occupied, control = ctrl)
+ print(Dynamic.cf)
+ ## round(varimp(Dynamic.cf), 4)
+ ## Standard importance values __________________________
+ imp=varimp(Dynamic.cf, conditional = TRUE) #use varimp defaults
+ ## plot(imp)
+ print(imp)
+
+ ## predict variables _________________________________________
+ predicted=predict(Dynamic.cf,OOB = TRUE)
+ print(occupied$Fan,predicted)
+
+ residual=occupied$Fan-predicted
+ mse=mean(residual^2)
+ rsq=1-mse/var(occupied$Fan)
+
+ ##Correlation between fitted values and original values: ____
+ correl <- paste(cor(occupied$Fan,predicted))
+ Correlation <-paste("MSE:",mse, "Rsq:",rsq, "Correlation between fitted values and original values:",correl)
+ print(Correlation)
+
+ ## combine results for output _______________________________
+ nam <- paste("Climate =",i, sep=" ")
+ assign(nam, 1:i)
+ results <- rbind(nam, mse, rsq, correl)
+
+ ## Writing data to csv file _________________________________
+ write.table(results, file = "variable importance3.csv", append = TRUE, quote = FALSE, sep = " ", col.names = TRUE, row.names = TRUE,)
+ write.table(imp, file = "variable importance3.csv", append = TRUE, quote = FALSE, sep = " ", eol = "\r", na = "N/A", row.names = TRUE, col.names = TRUE, qmethod = "double")
+ }



	[[alternative HTML version deleted]]

