Package edu.cmu.tetrad.sem
Class LargeScaleSimulation
java.lang.Object
edu.cmu.tetrad.sem.LargeScaleSimulation
Stores a SEM model, pared down, for purposes of simulating data sets with large numbers of variables and sample
sizes.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Constructor Summary
ConstructorsConstructorDescriptionLargeScaleSimulation(Graph graph) Constructor for LargeScaleSimulation.LargeScaleSimulation(Graph graph, List<Node> nodes, int[] tierIndices) Constructor for LargeScaleSimulation. -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]getCoefficientMatrix.getGraph()Getter for the fieldgraph.static intgetIndex.getKnowledge(Graph graph) getKnowledge.static intgetLag.getNameNoLag(Object obj) getNameNoLag.getOut()Getter for the fieldout.static StringgetPrefix.doubleGetter for the fieldselfLoopCoef.double[][]getSoCalledPoissonShocks(int sampleSize) getSoCalledPoissonShocks.double[][]getUncorrelatedShocks(int sampleSize) getUncorrelatedShocks.Getter for the fieldvariableNodes.booleanisVerbose.voidsetCoefRange(double coefLow, double coefHigh) setCoefRange.voidsetErrorsNormal(boolean errorsNormal) Setter for the fielderrorsNormal.voidsetIncludeNegativeCoefs(boolean includeNegativeCoefs) Setter for the fieldincludeNegativeCoefs.voidsetIncludePositiveCoefs(boolean includePositiveCoefs) Setter for the fieldincludePositiveCoefs.voidsetMeanRange(double meanLow, double meanHigh) setMeanRange.voidsetOut(PrintStream out) Setter for the fieldout.voidsetSelfLoopCoef(double selfLoopCoef) Setter for the fieldselfLoopCoef.voidsetVarRange(double varLow, double varHigh) setVarRange.voidsetVerbose(boolean verbose) Setter for the fieldverbose.simulateDataFisher(double[][] shocks, int intervalBetweenShocks, double epsilon) Simulates data using the model of R.simulateDataFisher(int sampleSize) Simulates data using the model of R.simulateDataFisher(int intervalBetweenShocks, int intervalBetweenRecordings, int sampleSize, double epsilon, boolean saveLatentVars) simulateDataFisher.simulateDataRecursive(int sampleSize) This simulates data by picking random values for the exogenous terms and percolating this information down through the SEM, assuming it is acyclic.simulateDataReducedForm(int sampleSize) Simulates data using the model X = (I - B)Y^-1 * e.
-
Constructor Details
-
Method Details
-
getPrefix
getPrefix.
-
getIndex
getIndex.
- Parameters:
s- aStringobject- Returns:
- a int
-
getLag
getLag.
- Parameters:
s- aStringobject- Returns:
- a int
-
simulateDataRecursive
This simulates data by picking random values for the exogenous terms and percolating this information down through the SEM, assuming it is acyclic. Works, but will hang for cyclic models, and is very slow for large numbers of variables (probably due to the heavyweight lookups of various values--could be improved). The model must be acyclic, or else this will spin.- Parameters:
sampleSize- a int- Returns:
- a
DataSetobject
-
simulateDataReducedForm
Simulates data using the model X = (I - B)Y^-1 * e. Errors are uncorrelated.- Parameters:
sampleSize- The nubmer of samples to draw.- Returns:
- a
DataSetobject
-
simulateDataFisher
Simulates data using the model of R. A. Fisher, for a linear model. Shocks are applied every so many steps. A data point is recorded before each shock is administered. If convergence happens before that number of steps has been reached, a data point is recorded and a new shock immediately applied. The model may be cyclic. If cyclic, all eigenvalues for the coefficient matrix must be less than 1, though this is not checked. Uses an interval between shocks of 50 and a convergence threshold of 1e-5. Uncorrelated Gaussian shocks are used.- Parameters:
sampleSize- The number of samples to be drawn. Must be a positive integer.- Returns:
- a
DataSetobject
-
simulateDataFisher
Simulates data using the model of R. A. Fisher, for a linear model. Shocks are applied every so many steps. A data point is recorded before each shock is administered. If convergence happens before that number of steps has been reached, a data point is recorded and a new shock immediately applied. The model may be cyclic. If cyclic, all eigenvalues for the coefficient matrix must be less than 1, though this is not checked.- Parameters:
shocks- A matrix of shocks. The value at shocks[i][j] is the shock for the i'th time step, for the j'th variables.intervalBetweenShocks- External shock is applied every this many steps. Must be positive integer.epsilon- The convergence criterion; |xi.t - xi.t-1| < epsilon.fff- Returns:
- a
DataSetobject
-
simulateDataFisher
public DataSet simulateDataFisher(int intervalBetweenShocks, int intervalBetweenRecordings, int sampleSize, double epsilon, boolean saveLatentVars) simulateDataFisher.
- Parameters:
intervalBetweenShocks- a intintervalBetweenRecordings- a intsampleSize- a intepsilon- a doublesaveLatentVars- a boolean- Returns:
- a
DataSetobject
-
getGraph
Getter for the field
graph.- Returns:
- a
Graphobject
-
setCoefRange
public void setCoefRange(double coefLow, double coefHigh) setCoefRange.
- Parameters:
coefLow- a doublecoefHigh- a double
-
setVarRange
public void setVarRange(double varLow, double varHigh) setVarRange.
- Parameters:
varLow- a doublevarHigh- a double
-
setMeanRange
public void setMeanRange(double meanLow, double meanHigh) setMeanRange.
- Parameters:
meanLow- a doublemeanHigh- a double
-
getOut
Getter for the field
out.- Returns:
- a
PrintStreamobject
-
setOut
Setter for the field
out.- Parameters:
out- aPrintStreamobject
-
isVerbose
public boolean isVerbose()isVerbose.
- Returns:
- a boolean
-
setVerbose
public void setVerbose(boolean verbose) Setter for the field
verbose.- Parameters:
verbose- a boolean
-
getCoefficientMatrix
public double[][] getCoefficientMatrix()getCoefficientMatrix.
- Returns:
- an array of objects
-
getVariableNodes
Getter for the field
variableNodes.- Returns:
- a
Listobject
-
getNameNoLag
getNameNoLag.
-
getKnowledge
getKnowledge.
-
getSoCalledPoissonShocks
public double[][] getSoCalledPoissonShocks(int sampleSize) getSoCalledPoissonShocks.
- Parameters:
sampleSize- a int- Returns:
- an array of objects
-
setIncludePositiveCoefs
public void setIncludePositiveCoefs(boolean includePositiveCoefs) Setter for the field
includePositiveCoefs.- Parameters:
includePositiveCoefs- a boolean
-
setIncludeNegativeCoefs
public void setIncludeNegativeCoefs(boolean includeNegativeCoefs) Setter for the field
includeNegativeCoefs.- Parameters:
includeNegativeCoefs- a boolean
-
setErrorsNormal
public void setErrorsNormal(boolean errorsNormal) Setter for the field
errorsNormal.- Parameters:
errorsNormal- a boolean
-
getSelfLoopCoef
public double getSelfLoopCoef()Getter for the field
selfLoopCoef.- Returns:
- a double
-
setSelfLoopCoef
public void setSelfLoopCoef(double selfLoopCoef) Setter for the field
selfLoopCoef.- Parameters:
selfLoopCoef- a double
-