BookmarkSubscribeRSS Feed
iaatoloye
Fluorite | Level 6

Hello, 

 

I have some data on net nitrogen mineralization and the values range from negative to positive. I measured nitrogen mineralization over several days and obtained the net nitrogen mineralization. I tried the approach below but could not obtain an output to merge to my data set. @Rick_SAS proc iml outputproc iml outputoriginal dataoriginal data

 

Thanks,

 

proc iml;
use work.idnet2;
read all var {NetNit };

LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */

LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */
idx = loc(NetNit > 0); /* find indices where Y > 0 */
if ncol(idx) > 0 then
LogNetNit [idx] = log10(NetNit [idx]);

print NetNit LNetNit LogNetNit ;

 

How do I obtain my output for further analysis? How do I obtain back-transformed means and standard errors??

With the LNetNit transformation, all values were positive? Is this acceptable?

With the LogNeNit, I had a lot of missing data and negative values.

5 REPLIES 5
Rick_SAS
SAS Super FREQ

If I understand your question, you don't want to check whether NetNit is positive, you want to check whether the translated data is positive:

 

proc iml;
use work.idnet2;
read all var {NetNit };
LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */

LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */
Y = NetNit + 1 - min(NetNit );   /* <== use the translated data */
idx = loc(Y > 0);      /* find indices where Y > 0 */
if ncol(idx) > 0 then
   LogNetNit[idx] = log10(Y[idx]);

print NetNit LNetNit LogNetNit ;
iaatoloye
Fluorite | Level 6

Yes, NetNit contains both negative and positive values and when I take the log of NetNit in Proc Glimmix, I end up having missing values.

However, with the code below, I have the data as positive values. I am not sure if this is a valid transformation approach. If it is, how do I use the output from proc iml in proc glimmix and back-transform the means?

 

LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */

 

I was hoping to get positive values with the code below but I ended up having missing and negative values.

 

LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */

Y = NetNit + 1 - min(NetNit );   /* <== use the translated data */

idx = loc(Y > 0);      /* find indices where Y > 0 */

if ncol(idx) > 0 then

   LogNetNit[idx] = log10(Y[idx]);

 

Thank you,

Rick_SAS
SAS Super FREQ

> I was hoping to get positive values with the code below but I ended up having missing and negative values.

 

The code will give you only nonnegative values for Y. If NetNit is missing, then Y will be missing (as it should). The code translates the data by some data-dependent value into the interval [1, infinity).

 

The interpretation is that you are measuring the data using some different baseline reference. For example, if you measure elevation from sea level, the elevations of Death Valley and the Mariana Trench are negative. But if you measure from one meter below the bottom of the Mariana Trench, then all elevations on earth are positive. In the language of distributions, you are translating the data distribution so that it has a new mean, but preserving other properties of the distribution.

 

I don't know your model, so I can't really comment on PROC GLMMIX. But I encourage you to consider whether you should log-transform negative values in the first place. 

iaatoloye
Fluorite | Level 6

Hello, 

 

I have some data on net nitrogen mineralization and the values range from negative to positive. I measured nitrogen mineralization over several days and obtained the net nitrogen mineralization. I tried the approach below but could not obtain an output to merge to my data set. 

 

Thanks,

 

proc iml;
use work.idnet2;
read all var {NetNit };

LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */

LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */
idx = loc(NetNit > 0); /* find indices where Y > 0 */
if ncol(idx) > 0 then
LogNetNit [idx] = log10(NetNit [idx]);

print NetNit LNetNit LogNetNit ;

 

How do I obtain my output for further analysis? How do I obtain back-transformed means and standard errors??

With the LNetNit transformation, all values were positive? Is this acceptable?

With the LogNeNit, I had a lot of missing data and negative values.proc iml outputproc iml outputDataData

Ksharp
Super User

Plz post it at IML forum since it is about SAS/IML .

And calling @Rick_SAS 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 5 replies
  • 1093 views
  • 1 like
  • 3 in conversation