<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Log transformation of negative values in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775406#M5703</link>
    <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I was hoping to get positive values with the code below but I ended up having missing and negative values.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 13:49:55 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2021-10-20T13:49:55Z</dc:date>
    <item>
      <title>Log transformation of negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775388#M5698</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684" target="_blank" rel="noopener"&gt;@Rick_SAS&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc iml output" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64877iC2267DBD1D669FA6/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS 10_20_2021 8_16_50 AM.png" alt="proc iml output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;proc iml output&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="original data" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64876iEBC7D5FB523E37BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS 10_20_2021 8_17_15 AM.png" alt="original data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;original data&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc iml;&lt;BR /&gt;use work.idnet2;&lt;BR /&gt;read all var {NetNit };&lt;/P&gt;
&lt;P&gt;LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */&lt;/P&gt;
&lt;P&gt;LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */&lt;BR /&gt;idx = loc(NetNit &amp;gt; 0); /* find indices where Y &amp;gt; 0 */&lt;BR /&gt;if ncol(idx) &amp;gt; 0 then&lt;BR /&gt;LogNetNit [idx] = log10(NetNit [idx]);&lt;BR /&gt;&lt;BR /&gt;print NetNit LNetNit LogNetNit ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I obtain my output for further analysis? How do I obtain back-transformed means and standard errors??&lt;/P&gt;
&lt;P&gt;With the LNetNit transformation, all values were positive? Is this acceptable?&lt;/P&gt;
&lt;P&gt;With the LogNeNit, I had a lot of missing data and negative values.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 12:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775388#M5698</guid>
      <dc:creator>iaatoloye</dc:creator>
      <dc:date>2021-10-20T12:54:24Z</dc:date>
    </item>
    <item>
      <title>Transforming and interpreting net values with positive and negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775383#M5700</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;use work.idnet2;&lt;BR /&gt;read all var {NetNit };&lt;/P&gt;&lt;P&gt;LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */&lt;/P&gt;&lt;P&gt;LogNetNit = j(nrow(NetNit ),1,.); /* allocate missing */&lt;BR /&gt;idx = loc(NetNit &amp;gt; 0); /* find indices where Y &amp;gt; 0 */&lt;BR /&gt;if ncol(idx) &amp;gt; 0 then&lt;BR /&gt;LogNetNit [idx] = log10(NetNit [idx]);&lt;BR /&gt;&lt;BR /&gt;print NetNit LNetNit LogNetNit ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I obtain my output for further analysis? How do I obtain back-transformed means and standard errors??&lt;/P&gt;&lt;P&gt;With the LNetNit transformation, all values were positive? Is this acceptable?&lt;/P&gt;&lt;P&gt;With the LogNeNit, I had a lot of missing data and negative values.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc iml output" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64875iF718096D5B5CE8EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS 10_20_2021 8_16_50 AM.png" alt="proc iml output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;proc iml output&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Data" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64874i108A0EF04F29F42E/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS 10_20_2021 8_17_15 AM.png" alt="Data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Data&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 12:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775383#M5700</guid>
      <dc:creator>iaatoloye</dc:creator>
      <dc:date>2021-10-20T12:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Transforming and interpreting net values with positive and negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775385#M5701</link>
      <description>&lt;P&gt;Plz post it at IML forum since it is about SAS/IML .&lt;/P&gt;
&lt;P&gt;And calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 12:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775385#M5701</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-20T12:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Log transformation of negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775391#M5699</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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 );   /* &amp;lt;== use the translated data */
idx = loc(Y &amp;gt; 0);      /* find indices where Y &amp;gt; 0 */
if ncol(idx) &amp;gt; 0 then
   LogNetNit[idx] = log10(Y[idx]);

print NetNit LNetNit LogNetNit ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 12:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775391#M5699</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-10-20T12:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Log transformation of negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775400#M5702</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LNetNit = log10(NetNit + 1 - min(NetNit )); /* translate, then transform */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping to get positive values with the code below but I ended up having missing and negative values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LogNetNit = &lt;STRONG&gt;j&lt;/STRONG&gt;(&lt;STRONG&gt;nrow&lt;/STRONG&gt;(NetNit ),1,.); /* allocate missing */&lt;/P&gt;&lt;P&gt;Y = NetNit + 1 - &lt;STRONG&gt;min&lt;/STRONG&gt;(NetNit );&amp;nbsp;&amp;nbsp; /* &amp;lt;== use the translated data */&lt;/P&gt;&lt;P&gt;idx = &lt;STRONG&gt;loc&lt;/STRONG&gt;(Y &amp;gt; 0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* find indices where Y &amp;gt; 0 */&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;ncol&lt;/STRONG&gt;(idx) &amp;gt; 0 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; LogNetNit[idx] = &lt;STRONG&gt;log10&lt;/STRONG&gt;(Y[idx]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 13:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775400#M5702</guid>
      <dc:creator>iaatoloye</dc:creator>
      <dc:date>2021-10-20T13:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Log transformation of negative values</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775406#M5703</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;I was hoping to get positive values with the code below but I ended up having missing and negative values.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 13:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Log-transformation-of-negative-values/m-p/775406#M5703</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-10-20T13:49:55Z</dc:date>
    </item>
  </channel>
</rss>

