<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title></title><style type="text/css">.felamimail-body-blockquote {margin: 5px 10px 0 3px;padding-left: 10px;border-left: 2px solid #000088;} </style></head><body>Hello<br><br>I am trying to <span class="st"><em>calculate statistical significance</em> of a <em>linear</em> trend (Regression analysis).<br>The regression analysis simple enough.<br><br>I have troubles understanding how the probabilities are computed based on the trend i calculate?<br>What i actually wanted to do is calculate the 2 tailed ttest probabilities but it doesn't seem possible with NCL, unless someone else knows of a way?<br>Or does </span><span class="st"><em class="quotelev3">using the NCL function "betainc" to get the p-value
for a student test is the same thing?<br><br></em>
<em class="quotelev3">>>></em>My code is below:<br><br><br>f = addfile ("air.mon.mean.nc", "r")<br> latS = 29.3<br> latN = 67.26 <br> lonL = 19.<br> lonR = 60.<br><br> TIME1 = f->time<br> YYYY1 = cd_calendar(TIME1,-1)/100 ; entire file<br> iYYYY1 = ind(YYYY1.ge.yrStrt .and. YYYY1.le.yrLast)<br> t2m = f->air(iYYYY1,:,:)<br> printVarSummary(t2m)<br><br> T2M = month_to_season (t2m, season)<br> printVarSummary(T2M)<br> nyrs = dimsizes(T2M&time)<br><br> t2mw = T2M({lat|latS:latN},{lon|lonL:lonR},time|:)<br> printVarSummary(t2mw)<br><br> t2mw = dtrend(t2mw,False)<br> printVarSummary(t2mw)<br><br> eofT = eofunc_Wrap(t2mw, neof, optEOF)<br> printVarSummary(eofT)<br><br>;==========================================================================<br>eof_regres= eofT ;create an array with meta data <br>do ne=0,neof-1<br>eof_regres(ne,:,:)= regCoef(eof_ts(ne,:), t2mw(lat|:,lon|:,time|:));<br> end do<br> printVarSummary(eof_regres)<br><br>;==========================================================================<br>;Calculate significance at 95% confidence<br>;The regCoef function returns the following attributes: yintercept (y-intercept), tval (t-statistic), rstd (standard error of the estimated regression coefficient) and nptxy (number of elements used). <br>;==========================================================================<br><br> df = onedtond(eof_regres@nptxy,dimsizes(eof_regres))-2 ; degrees of freedom<br> tval = onedtond(eof_regres@tval, dimsizes(eof_regres)) ; t-statistic<br><br> b = tval ; b must be same size as tval (and df)<br> b = 0.5<br> prob = betainc(df/(df+tval^2),df/2.0,b)<br> printVarSummary(prob) ; prob(nlat,nlon)<br><br> ;copy_VarCoords(eof_regres,prob)<br> prob@long_name = "probability"<br> ;prob@units = "fraction: [0,1]"<br><br> prob_95=where (prob.ge.0.95,1,0) ; **** note 0.95 ****<br> copy_VarCoords(prob, prob_95)<br> printVarSummary(prob_95) <br><br> eof_regres@long_name = "regression coefficient"<br> prob@long_name = "probability"<br> <br>;==================================The error message i get is:<br><br>warning:VarVarWrite: rhs has no dimension name or coordinate variable, deleting name of lhs dimension number (1) and destroying coordinate var, use "(/../)" if this is not desired outcome<br>warning:VarVarWrite: rhs has no dimension name or coordinate variable, deleting name of lhs dimension number (2) and destroying coordinate var, use "(/../)" if this is not desired outcome<br>warning:["Execute.c":8640]:Execute: Error occurred at or near line 135 in file NAOregreT2M_obs.ncl<br><br><br>Variable: eof_regres<br>Type: float<br>Total Size: 49856 bytes<br> 12464 values<br>Number of Dimensions: 3<br>Dimensions and sizes: [evn | 2] x [76] x [82]<br>Coordinates: <br> evn: [1..2]<br>Number Of Attributes: 11<br> tval : <ARRAY of 6232 elements><br> yintercept : <ARRAY of 6232 elements><br> rstd : <ARRAY of 6232 elements><br> nptxy : <ARRAY of 6232 elements><br> long_name : EOF: DJF: Monthly mean of surface temperature<br> _FillValue : -9.96921e+36<br> method : transpose<br> matrix : covariance<br> pcvar : ( 59.16475, 20.32462 )<br> eval : ( 18982.65, 6521.03 )<br> eval_transpose : ( 169.488, 58.22348 )<br><br><br></span></body></html>