countreg

countregViewStore

Description

The `countregViewStore` action allows for the inspection and display of a count regression model that has been previously fitted and saved into a CAS item store using the `countregFitModel` action. This is particularly useful for reviewing model details, such as parameter estimates, fit statistics, and covariance matrices, without needing to re-run the entire model fitting process. It essentially loads a saved model state and presents its information in various tabular formats.

proc cas; countreg.countregViewStore / display={...}, instore={...}, outputTables={...}, table={...}, timingReport={...}, viewOptions={...}; run;
Settings
ParameterDescription
displaySpecifies the list of display tables that you want the action to create. If you omit this parameter, all tables are created.
instoreSpecifies the input item store from which a regression model will be restored. You can then display various reports about the model.
outputTablesSpecifies the list of display tables that you want to output as CAS tables. If you omit this parameter, no tables are output as CAS tables.
tableSpecifies the input data table. This table is necessary to provide context, such as variable information, even though the model is loaded from the store.
timingReportSpecifies the kind of timing information that you want the action to provide.
viewOptionsSpecifies which reports to display about the regression model that is restored from an item store. Options include viewing all details, correlations, covariances, fit summaries, and more.
Data Preparation View data prep sheet
Creating the `science_articles` Dataset

This dataset simulates data about scientists. The goal is to model the number of articles published (`articles`) based on gender (`gender`), marital status (`married`), number of children (`kids`), prestige of their PhD program (`phd_prestige`), and number of mentorees (`mentorees`). This data will first be used to fit a model, which is then saved to an item store.

Copied!
1DATA casuser.science_articles;
2 INPUT gender $ married $ kids phd_prestige mentorees articles;
3 DATALINES;
4 Male Single 0 5 3 1
5 Female Married 2 2 0 2
6 Female Single 0 4 2 4
7 Male Married 1 1 1 1
8 Female Single 0 3 4 3
9 Male Married 3 3 2 0
10 Male Single 0 2 5 5
11 Female Married 1 4 1 2
12 ;
13RUN;

Examples

First, a simple Poisson regression model is fitted using `countregFitModel` and saved to an item store named `poisson_model_store`. Then, `countregViewStore` is used to display the minimal default information about the stored model.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 countreg.countregFitModel /
3 TABLE='science_articles',
4 model={depVars={{name='articles'}},
5 effects={{vars={'gender', 'married', 'kids', 'phd_prestige', 'mentorees'}}},
6 dist='POISSON'},
7 store={name='poisson_model_store', replace=true};
8 RUN;
9 countreg.countregViewStore /
10 TABLE='science_articles',
11 instore='poisson_model_store';
12RUN;
Result :
The action will display basic information about the restored model, typically including the model definition and fit summary, as `minimal=TRUE` is the default view option.

This example first fits a Negative Binomial model to account for overdispersion and saves it to `nb_model_store`. Then, `countregViewStore` is used with the `viewOptions={all=true}` parameter to display all available information for the restored model, including parameter estimates, correlations, and optimizer settings.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 countreg.countregFitModel /
3 TABLE='science_articles',
4 model={depVars={{name='articles'}},
5 effects={{vars={'gender', 'married', 'kids', 'phd_prestige', 'mentorees'}}},
6 dist='NEGBIN'},
7 store={name='nb_model_store', replace=true};
8 RUN;
9 countreg.countregViewStore /
10 TABLE='science_articles',
11 instore='nb_model_store',
12 viewOptions={all=true};
13RUN;
Result :
A comprehensive set of tables is displayed, including Model Definition, Fit Model Summary, Initial and Final Parameter Estimates, Covariance and Correlation matrices, and Optimizer Settings, providing a complete overview of the saved model.

This example demonstrates how to view specific reports, such as the parameter estimates and their covariance matrix, from a stored model. It also shows how to save the `Correlations` table to a new CAS output table named `model_correlations` for further analysis.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 countreg.countregViewStore /
3 TABLE='science_articles',
4 instore='nb_model_store',
5 viewOptions={finalEstimates=true, covariances=true, correlations=true},
6 outputTables={names={Correlations='model_correlations', replace=true}};
7RUN;
Result :
The output will show only the final parameter estimates, the covariance matrix, and the correlation matrix. Additionally, a new CAS table named `model_correlations` will be created in the active caslib, containing the correlation matrix of the parameter estimates.

FAQ

What is the purpose of the `countreg.countregViewStore` action in SAS Viya?
What are the required parameters for the `countreg.countregViewStore` action?
What does the `instore` parameter specify in the `countreg.countregViewStore` action?
What is the function of the `table` parameter?
Which options are available within the `viewOptions` parameter to control the displayed reports?
How can I output the display tables to CAS tables?
What is the default behavior if the `display` parameter is omitted?