How to get the R-square value in a MLR analysis using SVB? - Statistica Visual Basic - Statistica - Dell Community

# How to get the R-square value in a MLR analysis using SVB?

#### How to get the R-square value in a MLR analysis using SVB?

Does anyone know how to get the R-square value in a MLR analysis using SVB?

I wrote a VB program for MLR analysis, but I don't know how to copy the R-square value from the Multiple Regression Results form using program.

For example, when I using program finished a MLR, there should be a Multiple Regression Results, incude r-square, adjust r2, p, var1, var2 and so on. if I want Msgbox a r2 result, how to implement?

Robin

• Perhaps someone else can better answer this. nonlinear estimation is tricky because the output we need is only in the results window of the dialog and not accessible in a spreadsheet output. I am not sure how to grab pieces from that results window in SVB, but I do know a simple way to get R. R is simply the correlation between observed and predicted. So output the prediction output and use that as input in a correlation analysis to get R. here is some example code:

'#Reference {C9E29002-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Reference {C9E2900D-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Reference {C9E29001-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Language "WWB-COM"
Option Base 1
Sub Main

Dim newanalysis As Analysis
Set newanalysis = Analysis (scNonlinearEstimation, ActiveInputDataSet)

' Nonlinear Estimation:

newanalysis.Run

' User-Specified Regression, Least Squares:

newanalysis.Run

' Nonlinear Least Squares Model Estimation:

newanalysis.Run

' Results:

'create output of observed and predicted

'use prediction output as input in correlation matrix.
Dim newanalysis2 As Analysis
Set newanalysis2 = Analysis (scBasicStatistics, PredOutput)

' Product-Moment and Partial Correlations:

newanalysis2.Run

' Product-Moment and Partial Correlations:

Dim ModelRValue As Variant
MsgBox "The nonlinear model R is: " & ModelRValue

End Sub

All Replies
• assuming you are using the Multiple Regression tool and not GLM....

here is some SVB code that will use the active data set, let you select variables for regression and then output the R square of the model in a message box. I hope this helps.

'#Language "WWB-COM"
Option Base 1
Sub Main

Dim newanalysis As Analysis
Set newanalysis = Analysis (scMultipleRegression, ActiveInputDataSet)

newanalysis.Run

Dim Rstat As Variant

Set Rstat = Out1.Cells(2, 1)
MsgBox "the model R Square is: " & Rstat

End Sub

• Thank you so much!

And there is another question: I want get the R value in the NonlinearEstimation, but the same method can only get the values in the summary form, not include the R value.

'#Language "WWB-COM"
Option Base 1
Sub Main

Dim newanalysis As Analysis
Set newanalysis = Analysis (scNonlinearEstimation, ActiveInputDataSet)

newanalysis.Run

newanalysis.Run

newanalysis.Run

Dim Rstat As Variant

Set Rstat = Out1.Cells(1, 1)
MsgBox Rstat

End Sub

I can only get the values in the Nonlinear estimation results dialog. but how can I get the R in the Result form?

Model is: v1=......
Dependent variable: Var1               Independent variables: 5
Loss function: least squares
Final value: .01010969
Proportion of variance accounted for: .83815015    R =.91550541

Thanks!

• It seem that there is only one summary report form for nonlinear estimation, not inlude R value.

But in the header of result form, it showed Final value, Proportion of variance accounted for:XXX and R value,

How can I get them using SVB?

• Perhaps someone else can better answer this. nonlinear estimation is tricky because the output we need is only in the results window of the dialog and not accessible in a spreadsheet output. I am not sure how to grab pieces from that results window in SVB, but I do know a simple way to get R. R is simply the correlation between observed and predicted. So output the prediction output and use that as input in a correlation analysis to get R. here is some example code:

'#Reference {C9E29002-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Reference {C9E2900D-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Reference {C9E29001-3D45-11D4-9FF4-00C04FA0D540}#1.0#0#
'#Language "WWB-COM"
Option Base 1
Sub Main

Dim newanalysis As Analysis
Set newanalysis = Analysis (scNonlinearEstimation, ActiveInputDataSet)

' Nonlinear Estimation:

newanalysis.Run

' User-Specified Regression, Least Squares:

newanalysis.Run

' Nonlinear Least Squares Model Estimation:

newanalysis.Run

' Results:

'create output of observed and predicted

'use prediction output as input in correlation matrix.
Dim newanalysis2 As Analysis
Set newanalysis2 = Analysis (scBasicStatistics, PredOutput)

' Product-Moment and Partial Correlations:

newanalysis2.Run

' Product-Moment and Partial Correlations:

Dim ModelRValue As Variant