path analysis with Error in qr.default(S) : NA/NaN/Inf in foreign function call (arg 1)

For one of my courses involving Big data we were asked to merge several variables from different datasets into a single dataset, we have chosen the topic of response time and used SPSS to merge the several datasets into one. Literature study pointed to series of variables being responsible for response time, hence why we chose path analysis instead of regular regression. Spss does not fully support path analysis by means of chi and model fit, therefore we moved to R.

How I introduced the SPSS file into R, created the covariance matrix and defined the number of rows is the following;

ResponseTimeData = read.spss("file", to.data.frame = TRUE)

### variables that need to be excluded because not necessary
myvars <- names(ResponseTimeData) %in% c("Fire_ID","Hour_212223","Borough_5", "Loc_Zipcode", "Structural_Fires")
newdata <- ResponseTimeData[!myvars]

### There are some missing data points in a single variable (is this the correct form of putting this?)
ResponseFire <- na.omit(newdata)

### items for SEM
Num=length(ResponseFire[,1])
S=var(ResponseFire)

The variance matrix returns a warning In var(ResponseFire) : NAs introduced by coercion for which I do not know what to do about.
With missing values a path analysis can ofcourse not be conducted (or can it??)

Hoping someone can assist me in how to track the missing values (preferably without dropping the variable with the NA's...) or how to solve this.

Regards

The data is structured the following;

'data.frame':	10755 obs. of  30 variables:
 $ Date_weekend         : num  1 1 1 1 1 1 0 0 0 0 ...
 $ Hour_012             : num  0 0 1 0 0 0 0 0 0 0 ...
 $ Hour_345             : num  0 0 0 1 0 0 0 0 0 0 ...
 $ Hour_678             : num  1 0 0 0 0 0 0 0 1 0 ...
 $ Hour_91011           : num  0 1 0 0 0 0 0 0 0 0 ...
 $ Hour_121314          : num  0 0 0 0 0 1 0 0 0 0 ...
 $ Hour_151617          : num  0 0 0 0 0 0 0 1 0 1 ...
 $ Hour_181920          : num  0 0 0 0 1 0 1 0 0 0 ...
 $ ResponseTime_fire    : num  350 56 396 300 321 284 253 238 310 345 ...
 $ Borough_1            : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Borough_2            : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Borough_3            : num  1 1 1 1 1 1 1 1 1 1 ...
 $ Borough_4            : num  0 0 0 0 0 0 0 0 0 0 ...
 $ TrafficVolume        : num  536 938 817 471 1326 ...
 $ MedicalEmergencies   : num  0 0 1 0 1 1 0 0 0 1 ...
 $ NonMedicalEmergencies: num  1 1 0 0 0 0 0 1 1 0 ...
 $ NonStructural_Fires  : num  0 0 0 1 0 0 0 0 0 0 ...
 $ Severity_fire        : Factor w/ 8 levels "First Alarm",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Mean_Assigned_items  : num  1.333 2 0.333 0.333 0.333 ...
 $ Avg_Height           : num  64.4 64.4 64.4 64.4 64.4 ...
 $ Population           : num  2594676 2594676 2594676 2594676 2594676 ...
 $ Borough_Density      : num  14146 14146 14146 14146 14146 ...
 $ Rain                 : num  506 506 506 506 2262 ...
 $ Snow                 : num  6333 6333 6333 6333 24960 ...
 $ Windspeed            : num  2.34 2.34 2.34 2.34 3 3 2.4 2.4 2.4 2.7 ...
 $ Temp                 : num  0.1 0.1 0.1 0.1 1.65 1.65 2.1 2.1 2.1 5 ...
 $ Thunder              : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Heavy_fog            : Factor w/ 2 levels "0","1": 2 2 2 2 1 1 1 1 1 1 ...
 $ Smoke_Haze           : num  1 1 1 1 0 0 0 0 0 1 ...
 $ Icy_Road             : num  0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "na.action")= 'omit' Named int [1:446870] 1 2 3 4 5 6 7 8 9 10 ...
  ..- attr(*, "names")= chr [1:446870] "1" "2" "3" "4" ...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.