Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
25 replies Latest Post - ‏2015-01-21T07:05:59Z by DavidDub
SystemAdmin
SystemAdmin
109 Posts
ACCEPTED ANSWER

Pinned topic PS Matching command

‏2013-03-07T04:01:33Z |
Hi there,
I am running SPSS V20 and have downloaded the relevant R and plug-in files in order to generate the PS Matching icon under the Analyse command. When I use the drop down box in my data file to enter the relevant information (biary treatment indicator, covariates etc.) it comes up with a syntax error
Command name: PSMATCHING3
The first word in the line is not recognized as an SPSS Statistics command.
What am I doing wrong? I ran the syntax to check that the R Plug-in was working and the output showed it was.
Please help!
Updated on 2013-03-07T23:32:05Z at 2013-03-07T23:32:05Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    109 Posts
    ACCEPTED ANSWER

    Re: PS Matching command

    ‏2013-03-07T04:11:13Z  in response to SystemAdmin
    I guess you are using a third-party dialog, not the PSM dialog posted on this site. You should contact the author of that package for help. The one on this site does not require R, but it does require the Python Essentials and an update to the FUZZY extension command (also posted here).
    • SystemAdmin
      SystemAdmin
      109 Posts
      ACCEPTED ANSWER

      Re: PS Matching command

      ‏2013-03-07T23:32:05Z  in response to SystemAdmin
      Ok, I will give that a try.

      Thanks!
    • debbiehahsvaughn
      debbiehahsvaughn
      1 Post
      ACCEPTED ANSWER

      Re: PS Matching command

      ‏2013-05-31T14:37:33Z  in response to SystemAdmin

      I'm also receiving the same error.  Can you tell me exactly where I should be downloading PSM from in reference to the comment:  "I guess you are using a third-party dialog, not the PSM dialog posted on this site. You should contact the author of that package for help. The one on this site does not require R, but it does require the Python Essentials and an update to the FUZZY extension command (also posted here)."  Can you point me to more specifics on directions for the website for the PSM download and any other relevant details on what needs to be done?  Thank you.

      • JonPeck
        JonPeck
        49 Posts
        ACCEPTED ANSWER

        Re: PS Matching command

        ‏2013-05-31T15:32:02Z  in response to debbiehahsvaughn

        You can find the PSM dialog by following the Statistical Tools link on the Downloads for SPSS Statistics page.  The required updated FUZZY extension command can be found in the Extension Commands collection link on that same page.

  • KimAA
    KimAA
    8 Posts
    ACCEPTED ANSWER

    Re: PS Matching command

    ‏2013-05-16T12:24:11Z  in response to SystemAdmin

    Hello,

    I have been having the exact same problem as the person in the post above.  I have downloaded R and the appropriate plug-in - I ran the test and it appears to work properly.  I then downloaded psmatching3 from the sourceforge website and it seems to have downloaded and run successfully.  However, when I try to use the dialog, I get the same error line as above. 

    Error # 1.  Command name: PSMATCHING3. The first word in the line is not recognized as an SPSS statistics command.

    Did the original person posting this message resolve the issue????

    Thanks in advance!

     

    • JonPeck
      JonPeck
      49 Posts
      ACCEPTED ANSWER

      Re: PS Matching command

      ‏2013-05-16T13:52:34Z  in response to KimAA

      This extension command technically has an illegal command name - the name is longer than 8 characters.  I've never tried that to see what happens.  But assuming that everything gets truncated properly, there are a few things you can check.

      1) Restart Statistics after installing the bundle.

      2) If you are on Win7 or Vista, you might not have write permission to the default directory where the xml file that defines the syntax and the R file that implements the procedure are stored.  Different versions of Statistics handle this case differently.  See the FAQ on the Community site or extension command documentation for solutions for this problem.  You may want to search for PSMATCHING3.xml and PSMATCHING3.R to see where/whether these files were stored somewhere.

      HTH,

      Jon Peck

      • KimAA
        KimAA
        8 Posts
        ACCEPTED ANSWER

        Re: PS Matching command

        ‏2013-05-20T14:01:55Z  in response to JonPeck

        Hi Jon,

        Thanks for your helpful and speedy response.  The issue appeared to be in the file location.  I found another site with instructions on changing the environment variable for SPSS and I created a new file for PSMATCHING3 then downloaded the file again and overwrote the file in SPSS (while running as an administrator).  This seems to have resolved the problem regarding the command name; however, i now have a new problem. 

        Even as I downloaded the extension, I received an error saying that it had failed to download 'cem'.  I have since downloaded cem and Python separately and when I check in SPSS I can see that the CEM extension is there, but I am guessing it is not relating to R or something.  I have also tried to install CEM in R, but unsuccessfully. 

        Any new advice?!

        Kim

        • JonPeck
          JonPeck
          49 Posts
          ACCEPTED ANSWER

          Re: PS Matching command

          ‏2013-05-20T14:21:45Z  in response to KimAA

          This extension has nothing to do with Python, so anything you do with that will have no effect on it.

          If the cem download failed, maybe the site was down.  I downloaded cem (lower case) from CRAN without a problem.

          Trying running this in Statistics

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

          If cem is not installed in the R library, you will get an error.  You can install an R package manually by starting Rgui and using the Packages > Install Package(s) menu.  If that fails, you may a problem with permissions in your R library directory.  You can set the environment variable

          R_LIBS_USER

          to specify an alternative location for R library modules.

          • KimAA
            KimAA
            8 Posts
            ACCEPTED ANSWER

            Re: PS Matching command

            ‏2013-05-20T15:51:57Z  in response to JonPeck

            Thanks so much for your assistance.  I am still stuck as I try and set up library in R.  I can't even seem to find cem in the drop down links for packages and when I try to install.packages ("cem") manually I get the following error:

            Warning message:
            In getDependencies(pkgs, dependencies, available, lib) :
              package 'cem' is not available (for R version 2.14.2)
             

            Still fishing!!!

            • JonPeck
              JonPeck
              49 Posts
              ACCEPTED ANSWER

              Re: PS Matching command

              ‏2013-05-20T15:56:59Z  in response to KimAA

              I checked the package list for R2.14, and cem is not there.  It is present in 2.15, which is what I looked at before.  It appears that cem or a package it depends on is not available in 2.14.  Unfortunately, you can't use 2.15 with any released version of Statistics.

              • KimAA
                KimAA
                8 Posts
                ACCEPTED ANSWER

                Re: PS Matching command

                ‏2013-05-20T16:07:51Z  in response to JonPeck

                That makes sense then.  I seem to be in a circle of problems.  Okay, I will see what to do next.

                Many thanks!!

                • JonPeck
                  JonPeck
                  49 Posts
                  ACCEPTED ANSWER

                  Re: PS Matching command

                  ‏2013-05-20T17:02:59Z  in response to KimAA

                  One thing you might try is to go to the CRAN site from your browser (http://cran.r-project.org/), click on Pages on the left, find cem, download it, and try to install it via the R2.14 gui using Packages > Install from local zips.

                  As far as I can see, the package doc doesn't explicitly say R2.15, so it might be worth trying.  At least, it does no harm.

                  • KimAA
                    KimAA
                    8 Posts
                    ACCEPTED ANSWER

                    Re: PS Matching command

                    ‏2013-05-20T18:28:12Z  in response to JonPeck

                    Good suggestion.  I tried, both in R and from SPSS and I tried both the new and older versions of cem.

                    I received the following errors:

                     utils:::menuInstallLocal()
                    Warning in install.packages(choose.files("", filters = Filters[c("zip",  :
                      'lib = "C:/Program Files/R/R-2.14.2/library"' is not writable
                    Error in install.packages(choose.files("", filters = Filters[c("zip",  :
                      unable to create '~/R/library"' >  $HOME/.Renviron'
                    In addition: Warning message:
                    In dir.create(userdir, recursive = TRUE) :
                      cannot create dir 'C:\Users\Kimberley\Documents\R\library"' >  $HOME', reason 'Invalid argument'

                    I have written to R help and hope to get some feedback. 

                    I will let you know if i find a solution!
                     

                    • JonPeck
                      JonPeck
                      49 Posts
                      ACCEPTED ANSWER

                      Re: PS Matching command

                      ‏2013-05-20T18:44:47Z  in response to KimAA

                      That error indicates that you don't have write permission to the R library directory.  You might be able to get around this if you run R using Run As Administrator.  If not, create the R_LIB_USER environment variable as I suggested above.

                      Or install R itself somewhere other than under Program Files.

                      • KimAA
                        KimAA
                        8 Posts
                        ACCEPTED ANSWER

                        Re: PS Matching command

                        ‏2013-05-20T19:03:16Z  in response to JonPeck

                        Perfect solution.  I did this - I had been doing for SPSS but somehow didn't think to do so with R.  It worked perfectly and cem has downloaded.  Unfortunately, it has not resolved my overall problem.  SPSs first asked for randomForest - so I installed that in R.  However, it continues giving me errors - including ones suggesting the version may not be compatible.  The error is as follows:

                        Loading required package: randomForest

                        Error: package 'randomForest' could not be loaded

                        In addition: Warning messages:

                        1: package 'cem' was built under R version 3.0.1

                        2: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :

                        there is no package called 'randomForest'

                        Warning message:

                        In OK() : No warnings in estimation or matching procedure

                        Error: could not find function "imbalance"

                        SET SEED = 1234.

                        SET PRINTBACK=NONE.

                        Loading required package: randomForest

                        randomForest 4.6-7

                        Type rfNews() to see new features/changes/bug fixes.

                        Loading required package: tcltk

                        Loading Tcl/Tk interface ... done

                        Loading required package: combinat

                        Error: package 'combinat' could not be loaded

                        In addition: Warning messages:

                        1: package 'cem' was built under R version 3.0.1

                        2: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :

                        there is no package called 'combinat'

                        Error: object 'pt3' not found

                        Loading required package: combinat

                        Error: package 'combinat' could not be loaded

                        In addition: Warning messages:

                        1: package 'cem' was built under R version 3.0.1

                        2: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :

                        there is no package called 'combinat'

                        Warning message:

                        In OK() : No warnings in estimation or matching procedure

                        Error: could not find function "imbalance"

                         

                         

                        Seems to go on forever...

                        • JonPeck
                          JonPeck
                          49 Posts
                          ACCEPTED ANSWER

                          Re: PS Matching command

                          ‏2013-05-20T19:15:37Z  in response to KimAA

                          This is a journey!  Did you install the Ranfor extension bundle in Statistics?  That should have installed the R randomForest package or reported an error if it couldn't.  If you defined the environment variable, you would have needed to restart Statistics for that variable to be visible to it.

                           

                          I can see from the errors above, though, that cem itself depends on combinat, which you would also need to get and install.

                          Maybe it would be easier just to uninstall R and reinstall it in a writable directory - say \R2.14? That would at least resolve the issues with extension bundles for R packages that are available for that version of R.

                           

                          Updated on 2013-05-20T19:18:07Z at 2013-05-20T19:18:07Z by JonPeck
                          • KimAA
                            KimAA
                            8 Posts
                            ACCEPTED ANSWER

                            Re: PS Matching command

                            ‏2013-05-21T19:50:30Z  in response to JonPeck

                            A journey ..mmh...

                            And it continues.  I have removed and then reinstalled R as well as the Essentials for R.  I am also trying to do the same for PS Matching but as I installed them through SPSS Utilities 'install extensions' I am not sure now how to remove them.. I have PS Matching3 as well as the cem extension I downloaded from the CRAN site. 

                            Is it certain that SPSS 21 and R 2.14.2 and PSmatching3 are all compatible or should I be using different versions?

                             For now, I continue to get a similar error report:

                            Warning message:

                            In library (cem, logical.return = TRUE) : there is no package called 'cem'

                            Installing package (s) into 'C:/Program Files/IBM/SPSS/Statistics/21/extensions'

                            (as 'lib' is unspecified)

                            Warning message:

                            In getDependencies (pkgs, dependencies, available, lib) :

                            package 'cem' is not available (for R version 2.14.0)

                            Error in library (cem) : there is no package called 'cem'

                            Warning message:

                            In OK () : No warnings in estimation or matching procedure

                            Error: could not find function "imbalance"

                            As you will see from the error report, I have tried to download 2.14.0 in case that would make a difference and I placed it in the SPSS file. 

                            KIm

                            • JonPeck
                              JonPeck
                              49 Posts
                              ACCEPTED ANSWER

                              Re: PS Matching command

                              ‏2013-05-21T20:38:03Z  in response to KimAA

                              Please remember that PSmatching3 was not written by IBM.  We can promise that Statistics 21 and R2.14 are compatible, but we can't make any promises about PSmatching.  You should contact the authors of that extension for that information.

                              You should be able to install over a previous installation without removing things, but you can delete the files with the root name of PSmatching and extensions xml and .R.  The dialog can be uninstalled by opening it via Utilities > Custom Dialog Builder.

                              I'm not sure where this message came from:
                              package 'cem' is not available (for R version 2.14.0)
                              (I suspect the R package installer)

                              but you would probably have to go through the same process as earlier to get it and its dependencies.

                              • LareBuck23
                                LareBuck23
                                1 Post
                                ACCEPTED ANSWER

                                Re: PS Matching command

                                ‏2013-07-12T23:36:27Z  in response to JonPeck

                                Hi Jon,

                                I followed this string and tried everything as suggested. At first I thought it was going to work, then after the last try I got this message: 

                                Error: package/namespace load failed for 'cem'
                                 

                                This was after the initial error #1 message (error # 1. command name: psmatching3 >the first word in the line is not recognized as an spss statistics command. >execution of this command stops.). I then re-installed the psmatching3 .spe file from sourceforge... I then received the 'cem' error sequence, which I then loaded into R, fixed that. Then I got the 'randomForest' error. I loaded that, seemed ok. Then I got one more error 'combinat'.. I again found and loaded that into R. The last time I tried running my match, I received the above error. I run both SPSS and R as admin. Any thoughts?

                                Thanks, 

                                Pete

                                • JonPeck
                                  JonPeck
                                  49 Posts
                                  ACCEPTED ANSWER

                                  Re: PS Matching command

                                  ‏2013-07-18T01:45:01Z  in response to LareBuck23

                                  Check CRAN to make sure that all these packages are compatible with R 2.14.

        • JamieKim
          JamieKim
          2 Posts
          ACCEPTED ANSWER

          Re: PS Matching command

          ‏2014-07-15T01:36:26Z  in response to KimAA

          I am having the same problem as KimAA,

          "I have downloaded R and the appropriate plug-in - I ran the test and it appears to work properly.  I then downloaded psmatching3 from the sourceforge website and it seems to have downloaded and run successfully.  However, when I try to use the dialog, I get the same error line as above. 

          Error # 1.  Command name: PSMATCHING3. The first word in the line is not recognized as an SPSS statistics command."

           

          I am wondering how she was able to solve this problem and could you please provide more details on the processes -- "I found another site with instructions on changing the environment variable for SPSS and I created a new file for PSMATCHING3 then downloaded the file again and overwrote the file in SPSS (while running as an administrator)" ?

           

          Many thanks!! :)

           

           

          • JonPeck
            JonPeck
            49 Posts
            ACCEPTED ANSWER

            Re: PS Matching command

            ‏2014-07-15T16:47:09Z  in response to JamieKim

            That error message means that the syntax definition, which is contained in the XML file that is or should be part of the bundle, was not read.  You need to restart Statistics after installing the extension command.  If that does not solve the problem, then the PSMATCHING.xml file was not installed on the extension search path.

            To see where Statistics looks for extension command definitions, run

            SHOW EXT

            from a syntax window.  It will display a list of directories that are searched for the xml files that define extension syntax.  If the file is not in one of those locations, then there is probably something wrong with the package or your file permissions.  In the first case, you should contact the authors of the package for help.

            • KimAA
              KimAA
              8 Posts
              ACCEPTED ANSWER

              Re: PS Matching command

              ‏2014-08-21T16:05:21Z  in response to JonPeck

              Hello Jon and others,

              Just an update.  I did finally manage to get it all working.  To review - I have been trying to get PS Matching to work with SPSS 21 and R 2.14.2 and receiving most of the errors listed above.  

              In the end, I have now installed the latest version of PS Matching from source forge 3.03 - then opened R as an administrator and installed package 'combinat' using the package drop-down.  I then went on the cem website: http://gking.harvard.edu/cem/ and followed the instructions to install cem in R : To install, sign on to R, and type: install.packages("cem",repos="http://r.iq.harvard.edu", type="source") with the internet connected. 

               I have since been able to use PS Matching in spss - so far without any issues.

              Hope that helps!

              ‹Kim

               

              ​

              • JonPeck
                JonPeck
                49 Posts
                ACCEPTED ANSWER

                Re: PS Matching command

                ‏2014-08-21T21:05:32Z  in response to KimAA

                Thanks for posting a solution.

                • DavidDub
                  DavidDub
                  1 Post
                  ACCEPTED ANSWER

                  Re: PS Matching command

                  ‏2015-01-21T07:05:59Z  in response to JonPeck

                  Hello,

                  I was experiencing the same 'command line' not recognized error for PSMatching3 referred to in this thread and eventually overcame that (seemingly) by moving the xml file to a location with other like files. However, when I ran the procedure for the first time, there was a message about creating a library that I accepted and now each time I run the command I receive the following error:

                  Error in library(PSMATCHING3, lib.loc = .Library) :

                    there is no package called 'PSMATCHING3'

                  Error: could not find function "Run"

                  I have tried moving the PSMATCHING3.R file to various locations but to no avail.

                  Any help would be appreciated.

                  Thanks!