[ncl-talk] How to save print information for reg_multlin_stats

Herb, Jason jherb at albany.edu
Sat Oct 24 18:24:13 MDT 2020


Hello,
I'm working on a similar situation. Is there a way for NCL to take this nc file output and call it back into the script to get the R^2 value to plot it directly onto a plot? I have the script to plot text, but do not know how to refer to the "R^2" for NCL to feed it in.

Thanks
Jason
________________________________
From: ncl-talk <ncl-talk-bounces at mailman.ucar.edu> on behalf of Xueyan Zhang via ncl-talk <ncl-talk at mailman.ucar.edu>
Sent: Saturday, October 24, 2020 3:15 PM
To: Dennis Shea <shea at ucar.edu>
Cc: NCL-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] How to save print information for reg_multlin_stats

It works! Thank you!

Xueyan

On Sat, Oct 24, 2020 at 6:33 AM Dennis Shea <shea at ucar.edu<mailto:shea at ucar.edu>> wrote:
NCL variables are data structures (data objects) that mimic netCDF variables. Using Example 1 of http://www.ncl.ucar.edu/Document/Functions/Contributed/reg_multlin_stats.shtml

   :
   :
   print(b)

; Create netCDF file

   diro = "./"
   filo = "mult_reg.nc<http://mult_reg.nc>"
   ptho = diro + filo
   system<http://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml>("/bin/rm -f "+ ptho )    ; remove any previous file

   b!0  = "N"                      ; N=np+1
   b at information = "y-intercept; partial regression coefficients associated with each independent variable"
   b at long_name   = "Partial Regression Coefficients"
   delete(b at _FillValue)            ; not appropriate

   fo   = addfile<http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>(ptho,"c")
   fo->B= b                              ; NCL will write all components of the netCDF variable
===================

You can examine the file's contents via:

  %> ncdump -v B  mult_reg.nc<http://mult_reg.nc>

or

  %> ncl_filedump mult_reg.nc<http://mult_reg.nc>

====================

 %> ncdump -v B mult_reg.nc<http://mult_reg.nc>

netcdf mult_reg {
dimensions:
N = 3 ;
variables:
float B(N) ;
B:information = "y-intercept; partial regression coefficients associated with each independent variable" ;
B:long_name = "Partial Regression Coefficients" ;
B:model = "Yest = b(0) + b(1)*X1 + b(2)*X2 + ...+b(M)*XM" ;
B:N = 17 ;
B:NP = 2 ;
B:M = 3 ;
B:bstd = 0.f, 0.5029772f, 0.4922954f ;
B:SST = 13239.72f ;
B:SSE = 423.3723f ;
B:SSR = 12816.36f ;
B:MST = 827.4825f ;
B:MSE = 30.24088f ;
B:MSE_dof = 14 ;
B:MSR = 6408.178f ;
B:RSE = 5.499171f ;
B:RSE_dof = 13 ;
B:F = 211.9045f ;
B:F_dof = 2, 14 ;
B:F_pval = 3.419033e-11f ;
B:r2 = 0.9680232f ;
B:r = 0.9838817f ;
B:r2a = 0.9634551f ;
B:fuv = 0.03197682f ;
B:Yest = 249.9873f, 254.2619f, 257.2977f, 260.4574f, 266.3423f, 271.423f, 274.3349f, 279.6005f, 284.0294f, 285.7331f, 297.3181f, 300.1061f, 310.5743f, 314.0123f, 322.4051f, 334.5465f, 340.3705f ;
B:Yavg = 288.4f ;
B:Ystd = 28.766f ;
B:Xavg = 55.35294f, 30.9f ;
B:Xstd = 11.68028f, 1.172071f ;
B:stderr = 100.8641f, 0.3945341f, 3.931675f ;
B:tval = -1.521964f, 3.139713f, 3.073079f ;
B:pval = 0.1488179f, 0.006746806f, 0.007730724f ;
data:

 B = -153.5115, 1.238724, 12.08235 ;
}

On Fri, Oct 23, 2020 at 9:21 PM Xueyan Zhang via ncl-talk <ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>> wrote:
Hello all,

I am doing multiple variable linear regression following this page: https://www.ncl.ucar.edu/Document/Functions/Contributed/reg_multlin_stats.shtml.

How can I save R2 to a file? Also, how can I save information about which variable is significant?

Thanks!

Xueyan
_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201025/4fa38432/attachment.html>


More information about the ncl-talk mailing list