Learn R Programming

netSEM (version 0.5.1)

netSEMm: network Structural Equation Modeling (netSEM)

Description

This function carries out netSEM

Usage

netSEMm(x, exogenous = NULL, endogenous = NULL, nlsInits = data.frame(a1 =
  1, a2 = 1, a3 = 1), str = FALSE)

Value

An object of class netSEM, which is a list of the following items:

  • "table": A matrix. For each row, first column is the endogenous variable, second column is the predictor, the other columns show corresponding summary information: Best functional form, R-squared, adj-R-squared, P-value1, P-value2 and P-value3. The P-values correspond to those of estimators of linear regression coefficients. See details.

  • "bestModels": A matrix. First dimension indicates predictors. The second dimension indicates endogenous variables. The i-jth cell of the matrix stores the name of the best functional form corresponding to the j-th endogenous variable regressed on the i-th predictor.

  • "allModels": A three dimensional list. The first dimension indicates predictors. The second dimension indicates endogenous variables. Third dimension indicates the fitting results of all 6 functional forms. The i-j-k-th cell of the list stores a "lm" object, corresponding to the j-th endogenous, i-th predictor and the k-th functional form.

The object has two added attributes:

  • "attr(res.best, "Step")": A vector. For each variable, it shows in which step it is choosen to be significantly related to endogenous variable.

  • "attr(res.best, "diag.Step")": A matrix. First dimension is predictors; second dimension is endogenous variables. Each cell shows in which step the pairwise relation is being fitted.

Arguments

x

A dataframe. By default it considers all columns as exogenous variables, except first column which stores the system endogenous variable.

exogenous,

by defult it consideres all columns as exogenous variables except column number 1, which is the main endogenous response.

endogenous

A character string of the column name of the main endogenous OR a numeric number indexing the column of the main endogenous.

nlsInits

a data frame of initial vectors for nls. Each column corresponds to a coefficient. The data frame can be generated by the genInit() function. Each row is one initial vecotor. Currently the only nls function included is y = a + b * exp(c * x).

str

A boolean, whether or not this is a 'strength' type problem

Details

netSEM builds a network model of multiple continuous variables. Each pair of variables is tested for sensible paring relation chosen from 7 pre-selected common functional forms in linear regression settings. Adjusted R-squared is used for model selection for every pair.

P-values reported in the "res.print" field of the return list contains the P-values of estimators of linear regression coefficients. The P-values are ordered in the common order of coefficients, i.e. in the order of increasing exponents. For example, in the quadratic functional form y ~ b0 + b1x + b2x^2, the three P-values correspond two those of \hatb0, \hatb1 and \hatb2, respectively. If there are less than 3 coefficients to estimate, the extra P-value field is filled with NA's.

Examples

Run this code
## Load the sample acrylic data set
data(acrylic)

## Run netSEM
ans <- netSEMm(acrylic)

## Subset dataset
res <- subsetData(ans,cutoff=c(0.3,0.6,0.8))

## Plot the network model with adjusted-R-squred of c(0.3,0.6,0.8)
plot(ans,res)

## Summary
summary(ans)

## Extract relations between IrradTot and IAD2
cf <- path(ans,from ="IAD2",to="IrradTot")
print(cf)

## Print three components of the result
ans$table
ans$bestModels
ans$allModels

Run the code above in your browser using DataLab