Topic
21 replies Latest Post - ‏2013-11-09T14:09:35Z by JonPeck
danjohnson10
danjohnson10
4 Posts
ACCEPTED ANSWER

Pinned topic tobit regression not working

‏2011-07-21T21:46:39Z |
Using SPSS version 18.0.0 if that makes any difference (updating to later versions seems to require a username and password to any of the sites with the patches).

So I downloaded the tobit extension, then downloaded the latest version of R, only to find out that the extension apparently only works with R-2.8 so I uninstalled R 2.13 and installed 2.8, then found out I need the AER package for R, so downloaded that and installed it from the zip file into R. However, whenever I try to run a tobit regression in SPSS I get an error message saying that the R AER package is required but could not be located. Very frustrating. Any ideas?

Just to make sure a tobit regression is what I need, is tobit regression appropriate for limited dependent variables that can assume negative values? For example in the whole number range from -9 to 9?

Thank you.
Updated on 2012-09-19T14:25:47Z at 2012-09-19T14:25:47Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    396 Posts
    ACCEPTED ANSWER

    Re: tobit regression not working

    ‏2011-07-22T02:15:21Z  in response to danjohnson10
    There are several points here.

    First, installing the R Esssentials requires a particular version of R corresponding to the SPSS Statistics version. Installation instructions specify the version - 2.8.1 is right for Statistics 18, but you can have multiple R versions installed, and Statistics will use the appropriate one. Currently I have four R versions on my system.

    Second, the packages that are installed with the R Essentials, including tobit IIRC, will download and install the dependent packages when you install them if possible. (Some R-based packages on this site are not packaged as spe files and require you to download those packages manually.)

    If you installed AER manually, perhaps you installed it the wrong version of R. Each R version requires its own set of package installations.

    Now the bottom line: tobit is designed for regression-type relationships where ONE side is censored (you can specify the censoring point). It does not handle the doubly censored case. To suggest techniques for that it would be necessary to know more about why the range is bounded and the nature of the model.

    HTH,
    Jon Peck
    • danjohnson10
      danjohnson10
      4 Posts
      ACCEPTED ANSWER

      Re: tobit regression not working

      ‏2011-07-22T05:22:15Z  in response to SystemAdmin
      Thank you for your response.

      First, I know I am using the correct R version (2.8.1) because I uninstalled the incorrect R version - only one version installed now.

      But your second point may have hit it. The R plugin I installed for SPSS is this one: PASWStatistics_RPlugIn_1802_win32.exe. But as I mentioned I am running SPSS 18.0.0. I suppose that could be the problem, but it also seems the problem occurs downstream of this plugin. I mean the error message I get refers to the AER plugin for R (saying it couldn't be loaded); it doesn't refer to the R plugin for SPSS. Also, just now trying to run a tobit regression again I got an additional error message saying "package 'AER' was built under R version 2.13.1".

      So I guess there are potentially two problems. One, that I can't find an available patch to update to SPSS 18.0.2 (or alternatively I can't find an R plugin for SPSS 18.0.0). And two that I may have installed the wrong version of AER, even though AER 1.1-8 supposedly works with R (>=2.5.0), according to the author of AER.

      Now, regarding my intent with tobit, should you be inclined to offer suggestions. I am trying to predict the cumulative score of a respondent's answers to a survey. Each individual answer can take a value of -1, 0, or 1. There are 9 questions, hence a dependent variable range of -9 to 9. I originally performed a multiple linear regression and the residuals were normally distributed, but it was suggested that because the Y range is limited I should look into logit or tobit regression. A similar study that I followed in part had a range of 0 to 11, which I now realize is one sided, as opposed to my two sided range. However, I don't see why I can't just bump up the range by 9 to make it 0 to 18. The value itself isn't important, it's all relative.

      Any help is appreciated.
      • SystemAdmin
        SystemAdmin
        396 Posts
        ACCEPTED ANSWER

        Re: tobit regression not working

        ‏2011-07-22T13:04:55Z  in response to danjohnson10
        If you get the message about AER, it means that the plugin is working, because it is running R code. You can test this and whether AER is present with this simple program.
        begin program r.
        print(sessionInfo())
        library(AER)
        end program.

        Assuming that runs but AER is not found, start R gui from the Start menu and try
        library(AER)

        If that doesn't work, AER is definitely not installed. Use the Packages menu in R to install it.

        As for the version of AER, usually a mismatch between the library build and the R version is harmless, but installing the package from R gui should get the right version if it is available. The SPSS R Essentials would also have attempted to get the right version.

        Regarding patching SPSS v18, I don't know whether v18 patches are still available. Please contact Technical Support to see if they can help.

        As for the appropriateness of tobit regression for your problem, I am doubtful. The tobit model is one where the outcome can be described by a linear regression except that one side has a truncation point. Most often that is zero, but the actual value doesn't matter. But the model assumes that the other side is not truncated. In your case, not only is there a boundary on both sides, but the actual possible values are discrete (integers), which is not consistent with a regression model. If you plot the regression residual against the fitted values, I expect that you will see a clear nonrandom pattern.

        If the distribution of the outcomes has thin tails near the limit points, you might want to just ignore this problem, but if not, then other techniques might work better.

        Categorical regression (CATREG in the Categories option) might be an appropriate technique.
        Another would be to treat this as count data (after rescaling to nonnegative values) and use Poisson regression or a similar model for count data (GENLIN).

        HTH,
        Jon Peck
        • danjohnson10
          danjohnson10
          4 Posts
          ACCEPTED ANSWER

          Re: tobit regression not working

          ‏2011-07-22T17:07:42Z  in response to SystemAdmin
          Thank you, I have now successfully installed AER (using packages menu) and am able to do tobit regression.

          I will look into your other suggestions for regressions but I still think I am ok with either a standard linear or tobit regression. The distribution of the dependent variable looks normally distributed (though it doesn't pass the K-S or S-W tests), but the distribution of the linear regression residuals passes the normality tests. Even though the limits are -9 to 9, out of 260 cases the lowest value is -7, with one case, and only two cases at +9. So, like you said, maybe I should just ignore the problem.

          Anyways, thanks.
          • SystemAdmin
            SystemAdmin
            396 Posts
            ACCEPTED ANSWER

            Re: tobit regression not working

            ‏2011-07-22T17:13:50Z  in response to danjohnson10
            Glad that this is working, but since you have almost no data near/at the limits, it is probably very reasonable to ignore the limit problem.

            Regards,
            Jon
            • danjohnson10
              danjohnson10
              4 Posts
              ACCEPTED ANSWER

              Re: tobit regression not working

              ‏2011-07-26T19:01:20Z  in response to SystemAdmin
              Another stats question....

              I have a tobit model now, a generalized linear model with poisson distribution, and my original linear model. I think we've already established there is justification for any one of these, but now I want to compare all of them and pick the best one. I wanted to use AIC but SPSS (running r plugin) doesn't report that for tobit, nor does it report RSS for tobit. So in comparing the genlin model with tobit I used the log-likelihood value which slightly favors the genlin model (being less negative). Then in comparing the genlin model with the linear model, because SPSS doesn't report a likelihood value for linear models I calculated the AIC value instead, which is 1.5 times that of the genlin model. I therefore have concluded the genlin model is the best. Am I right to conclude that based on these mixed value comparisons?
        • JasY
          JasY
          2 Posts
          ACCEPTED ANSWER

          Re: tobit regression not working

          ‏2013-08-27T18:25:30Z  in response to SystemAdmin

          Hello, I have same problem when I run Tobit regression in SPSS. They say "The R AER package is required but could not be loaded"

          I use Library(AER) in R and no AER.  And I tried to use the Packages menu in R to install it. And get the error message below. Any idea? Thanks!

           

          Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.14
          Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
            'lib = "C:/Program Files/R/R-2.14.2/library"' is not writable
          Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
            unable to install packages
           

          Updated on 2013-08-27T18:26:20Z at 2013-08-27T18:26:20Z by JasY
  • RMANelissen
    RMANelissen
    2 Posts
    ACCEPTED ANSWER

    Re: tobit regression not working

    ‏2012-09-19T08:41:03Z  in response to danjohnson10
    I encountered the following error message after trying to run a Tobit regression in SPSS (I am usin SPSS 19 and installed R 2.10 and the TOBIT extension as indicated on the Development Central):

    >Error # 6890. Command name: BEGIN PROGRAM
    >Configuration file spssdxcfg.ini is invalid.
    >Execution of this command stops.
    Configration file spssdxcfg.ini is invalid because the LIB_NAME is NULL.

    Any idea what went wrong?

    Thanks,
    Rob
    • SystemAdmin
      SystemAdmin
      396 Posts
      ACCEPTED ANSWER

      Re: tobit regression not working

      ‏2012-09-19T12:35:10Z  in response to RMANelissen
      That message usually indicates that the R Essentials are not installed. If you did install them, try uninstalling and reinstalling the Essentials. If you are on Win7, be sure to do this install using Run As Administrator.

      Check the R installation by running this from a syntax window.

      begin program r.
      print('ok')
      end program.

      I expect that you will get the same failure message.

      HTH,
      Jon Peck
      • RMANelissen
        RMANelissen
        2 Posts
        ACCEPTED ANSWER

        Re: tobit regression not working

        ‏2012-09-19T14:11:04Z  in response to SystemAdmin
        Thanks for your reply. I am not sure this is the problem though. I re-installed the Extension but get the same error message. Also, if I enter your commands in an SPSS syntax file, I do not get an error message, but simply an output with a log detailing the syntax.

        Just to be sure; after I downloaded the files, I got a folder called Download Director, which contains: a zip folder called "Essentials_for_R_Installation_Instructions_19_win.zip", another zip folder called "R_plugin_code_v19.zip", and another one called "19.0-IM-S19SREAD-WIN32-FP002.zip", plus two files called "dlmgr.pro" and "SPSS_Statistics_REssentials_19002_win32.exe". I subsequently unpacked the zip folders and ran the EXE program (I am using Windows XP). This should do the trick, or am I missing something?
        • SystemAdmin
          SystemAdmin
          396 Posts
          ACCEPTED ANSWER

          Re: tobit regression not working

          ‏2012-09-19T14:25:47Z  in response to RMANelissen
          If you did not get the "ok" printed out from the little test program, something is definitely broken in the basic plugin.

          For installation, only the exe file matters.

          Some XP systems have a lot of restrictions on applications. Sometimes the whole C drive is not writable. Please contact Technical Support to see if they can figure out what is wrong here. There are some tips in the FAQ on this site, but none seems directly applicable to your situation.
  • JasY
    JasY
    2 Posts
    ACCEPTED ANSWER

    Re: tobit regression not working

    ‏2013-08-27T18:28:10Z  in response to danjohnson10

    Re: tobit regression not working

    Today 2:26 PM in response to SystemAdmin

    Hello, I have same problem when I run Tobit regression in SPSS. They say "The R AER package is required but could not be loaded"

    I use Library(AER) in R and no AER.  And I tried to use the Packages menu in R to install it. And get the error message below. Any idea? Thanks!

     

    Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.14
    Warning in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
      'lib = "C:/Program Files/R/R-2.14.2/library"' is not writable
    Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
      unable to install packages

     

    • JonPeck
      JonPeck
      46 Posts
      ACCEPTED ANSWER

      Re: tobit regression not working

      ‏2013-08-27T23:11:10Z  in response to JasY

      When you install an R-based extension bundle, the installer attempts to download and install any required R packages.  The messages indicate two problems.

      1) The R repository could not be accessed.  There might be a problem with your internet connection or firewall settings

      2) Since you installed R under Program Files, and assuming that you are on Windows 7, you do not have write permission to the normal areas where packages are installed.  To solve this problem, start Statistics or R, if you want to install the packages that way, using Run As Administrator.

      If you don't have the rights to do that, you will need someone to install under an admin account, or you could install R in a location not under Program Files, which usually means you don't need admin permissions.

    • JonPeck
      JonPeck
      46 Posts
      ACCEPTED ANSWER

      Re: tobit regression not working

      ‏2013-11-09T14:09:35Z  in response to JasY

      Your system is set up so that the default R package location cannot be written to with normal privileges.  Try starting Rgui using Run As Administrator and installing the package.

      Or, if you are going to be installing more items, you might want to remove R and reinstall it (and the R Essentials) in a directory that is not under Program Files.

  • Andreap
    Andreap
    4 Posts
    ACCEPTED ANSWER

    Re: tobit regression not working

    ‏2013-10-16T18:19:54Z  in response to danjohnson10

    Hello,

    I am sorry if my question is stupid but I am new at using R programmability.

    I installed everything following the instructions found on this website, that is the appropriate version of R, and of R essentials, so now I have new commands in my SPSS menu. I am able to choose a tobit regression, the dialogue box seems fine, I can include my variables and everything, but when I run it, nothing appears on my output window, except the syntax of my analysis - but no output of that analysis! what am I missing?

    thank you in advance.

    • JonPeck
      JonPeck
      46 Posts
      ACCEPTED ANSWER

      Re: tobit regression not working

      ‏2013-10-16T18:50:18Z  in response to Andreap

      I can't tell for sure what the cause might be, but probably the R Essentials is not installed correctly.  Open a syntax window and run this program.

      begin program r.
      sessionInfo()
      end program.

      If you get no output, it's a general problem with the Essentials install.

      One cause of this could be a mismatch between the Statistics version bitsize and the Essentials bitsize.  They both need to be 32 or both 64.  You can't mix them but the installer doesn't always detect this.  If you need to report back, please specify what version of Statistics you are using and what OS you are running on.

      • Andreap
        Andreap
        4 Posts
        ACCEPTED ANSWER

        Re: tobit regression not working

        ‏2013-10-17T09:56:18Z  in response to JonPeck

        thanks for your answer.

        I run your syntax and again no output.

        I have a 32bits PC with OS 7, on which SPSS 19 is installed. I installed R 2.10.0, and SPSS_Statistics_REssentials_19002_win32. I don't know how to check with bitsize version my spss is but I am pretty sure it's a 32 (would it even work on a 32 pc if it were a 64 bits?). I was careful to install the Essentials with a right-click and "execute as administrator".

        what is wrong??

        • JonPeck
          JonPeck
          46 Posts
          ACCEPTED ANSWER

          Re: tobit regression not working

          ‏2013-10-17T12:47:03Z  in response to Andreap

          You will probably need to contact Technical Support, but here is one more possibility.

          Check the setting of your SPSS temporary directory using Edit > Options > Files.  Make sure that the path does not contain any blanks or accented characters.

          Also, look in the library subdirectory under your R installation.  It should have a directory named spss190 with a bunch of subdirectories.  If it does not or if this is empty, then the plugin installation did  not succeed.

          And in the SPSS installation directory, check for a file named InvokeR.dll.  There should also be a file named

          spssdxcfg.ini

          It should show X=R under Supported_lang and it should have a block of specifications under the R section, including a HOME setting pointing to the R installation directory.

           

          • Andreap
            Andreap
            4 Posts
            ACCEPTED ANSWER

            Re: tobit regression not working

            ‏2013-10-17T13:32:11Z  in response to JonPeck

            Check the setting of your SPSS temporary directory using Edit > Options > Files.  Make sure that the path does not contain any blanks or accented characters.

            => no such problem here

            Also, look in the library subdirectory under your R installation.  It should have a directory named spss190 with a bunch of subdirectories.  If it does not or if this is empty, then the plugin installation did  not succeed.

            => I was not able to find it. I desinstalled and reinstalled both R and the essentials, with the same result...

            And in the SPSS installation directory, check for a file named InvokeR.dll. 

            => yes, there is

            There should also be a file named

            spssdxcfg.ini

            It should show X=R under Supported_lang and it should have a block of specifications under the R section, including a HOME setting pointing to the R installation directory.

            => under Supported_lang, it says: 

            X=PYTHON;R[R]
            but I suppose this is because I additionally installed the python essentials (I initially thought there were necessary)
            the rest seems ok:
            HOME=C:/Program Files/R/R-2.10.0/
            LIB_NAME=statisticsr
            INIT_EMBEDDED_X=Rf_initEmbeddedR_M
            EXECUTE_X=voidEval
            STOP_EMBEDDED_X=Rf_endEmbeddedR_M
            SET_POST_SPSS_OUTPUT=SetSpssOutput
            PRE_ACTION=library(spss190) \tn prespss()
            POST_ACTION=postspss()
             

            now is another stupid question: how do I contact technical support?

            Thank you again for your help.

            • JonPeck
              JonPeck
              46 Posts
              ACCEPTED ANSWER

              Re: tobit regression not working

              ‏2013-10-17T13:40:35Z  in response to Andreap

              If you don't have the spss190 library directory under C:/Program Files/R/R-2.10.0, then things are certainly not going to work.  The only cause I can think of that would cause that is lack of write permission.  Since Program Files has special restrictions in Win7, try uninstalling R and the Essentials and installing R in a location that is not under Program Files, say R2.10 and then reinstalling the Essentials.

              See the bookmark list on the main SPSS Community site for links to Technical Support.  You must have a support contract to use this.  If you are a student, see the special topic on student TS.

              • Andreap
                Andreap
                4 Posts
                ACCEPTED ANSWER

                Re: tobit regression not working

                ‏2013-10-23T09:52:36Z  in response to JonPeck

                Thank you for your help.

                I tried your last suggestion with the same result... very frustrating.

                I contacted technical support as you suggested, so now let's wait and hope they'll be able to find a solution.