The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
June 2010 - Posts - TIBCO Spotfire FAQ

TIBCO Spotfire FAQ

June 2010 - Posts

  • Running multiple TIBCO Spotfire S+ sessions

    To start multiple sessions of TIBCO Spotfire S+ running on the same machine, use the flag /MULTIPLEINSTANCES. 

    This can be added to the Target: line of your S+ shortcut icon in Windows.  Every time the modified shortcut is clicked, a new instance of S+ will open.  To set this flag, right-click on your S+ icon and select "Properties".  Scroll to the end of the Target: line, add a space, and then ‘/MULTIPLEINSTANCES'.    The target line would then read:


    For S+ 6.2     "C:\Program Files\Insightful\splus62\cmd\SPLUS.exe" /MULTIPLEINSTANCES

    For S+ 7.0     "C:\Program Files\Insightful\splus70\cmd\SPLUS.exe" /MULTIPLEINSTANCES

    For S+ 8.0     "C:\Program Files\Insightful\splus80\cmd\SPLUS.exe" /MULTIPLEINSTANCES

    For S+ 8.1     "C:\Program Files\TIBCO\splus81\cmd\SPLUS.exe" /MULTIPLEINSTANCES


    Click "Ok" to apply the settings and close the dialog box.  You will need to do this to all icons you use to start S+.

  • Contrasts: Coding of Factors in TIBCO Spotfire S+

    Why does the output from a model with N-level factor variable return only N-1 coefficients?  

    To demonstrate contrasts or the coding of factors in TIBCO Spotfire S+ consider the following S+ session in which an analysis of variance model is fit with the aov() function:


       # Examine the built-in dataset 'guayule'.

       > names(guayule)

       [1] "variety" "treatment" "reps" "plants" "flats"

       > dim(guayule)

       [1] 96 5


       # Pick two columns from the dataset for an aov() model.

       > c(data.class(guayule$variety), data.class(guayule$treatment))

       [1] "factor" "factor"

       > c(length(levels(guayule$variety)),


       [1] 8 4


       # Example call to aov().

       > tgaov <- aov(plants ~ variety * treatment, data = guayule)

       > summary(tgaov)

       Df Sum of Sq Mean Sq F Value Pr(F)

       variety 7 763.16 109.02 2.7058 0.01604076

       treatment 3 30774.28 10258.09 254.5959 0.00000000

       variety:treatment 21 2620.14 124.77 3.0966 0.00026666

       Residuals 64 2578.67 40.29


       # Note that the degrees of freedom for both factor columns is one less

       # than the number of levels in the column. This means that for a

       # factor with n levels, only n-1 parameters are fit in the model.


    This is a result of the way that S+ numerically codes the levels of a factor variable when it includes them in a model computation.  Pages 39-40 in Volume 1 of the "TIBCO Spotfire S+ 8.1 Guide to Statistics" provide a general explanation for this choice in fitting factor variables.  Basically, overparameterization can occur when each level of a factor variable is with its own coefficient.  Instead, linear combinations of the factor levels are fit, and a factor with N levels will have N-1 possible (independent) linear combinations.  This means that only N-1 coefficients will be returned.

    By default, most model functions that require contrasts use the value of

       > options()$contrasts

    to determine their coding scheme.  Currently, there are Helmert contrasts, polynomial contrasts, sum contrasts, and treatment contrasts built into S+.  Sum contrasts produce coefficients whose sum is zero, and treatment contrasts produce dummy coefficients in which the first level of the factor is zeroed out.  For more details on any of these coding schemes, you can type '?contr.helmert' at the S+ prompt to see their common help file.

    As a supplement to the discussion above, you may want to reference "Modern Applied Statistics with S" by W.N. Venables and B.D. Ripley (Fourth Edition).  This text gives a more theoretical discussion on the relationship between the coefficients for contrasts and the coefficients for factor levels.

  • Command Line: How TIBCO Spotfire S+ deals with local and global variables.

    What is the scope of variables during function evaluation?

    - All variables created during function evaluation will be local variables which exist until the function completes and returns its output value.

    - When function A calls function B, a different set of local variables will be created, some of which may have the same names as those in function A.  To keep track of the different variables and their values, TIBCO Spotfire S+ uses "frames".


    What is a frame?

    - A frame is best thought of as a set of temporarily stored S+ objects.

    - Unlike objects in directories on the 'search()' list, which are files stored on a hard disk, the contents of a frame are stored in memory.

    - A frame can exist, at the longest, for the duration of the S+ session.

    - Objects stored in frames can be accessed more quickly than objects stored in directories, because they reside in memory, rather than on the hard drive.


    How are frames organized?

    - The _session_ frame (frame 0) exists for the duration of the S+ session. It holds objects that can reasonably be expected to start over from default values, such as '.Options'.

    - The _expression_ frame (frame 1) holds objects throughout the evaluation of a typed expression.  Objects in the expression frame disappear after the complete evaluation of the top-level expression.

    - During the evaluation of an expression, higher numbered fames (frame n, where n>=2) are created temporarily.


    When S+ searches for objects, it looks for them in each of the following locations, in the order shown:

    - the local frame (frame n)

    - the expression frame (frame 1)

    - the session frame (frame 0)

    - the directories in the 'search()' path


    What this means:

    - This means that if you are in frame 7, and want to access something in frame 6 (for example, during the execution of a function), some special provisions are necessary.

    - A key point to remember is that it doesn't matter how deeply nested your calls become: the search path always jumps from the current evaluation frame to frame 1, bypassing all of the evaluation frames in between.



    Resources for further information on S+ evaluation frames:


    Chapter 2 of the TIBCO Spotfire S+ 8.1 Programmer's Guide for Windows has the most complete treatment of this subject.

    You can also find information related to the use of S+ frames in the on-line help files that are displayed when you type the following expressions at the S+ command-line prompt:









    Q&A which illustrates the discussion above on frames:




    "I wrote the following simple function to fit an 'lm()' model and plot the fit. Why do I get an error, and how do I get this to work?"


    my.lm.func <- function(my.formula,


       fit <- lm(my.formula,

       old.par <- par(mfrow = c(3, 2))

       on.exit(par <- old.par)





    Output of a call to this function:

    > my.lm.func(Mileage~Weight,fuel.frame)

    Error: Object "my.formula" not found





    The problem has to do with where S+ looks for objects. As "my.formula" is not one of the arguments to 'plot()' and is not in any directories in the search list, it cannot be found by 'plot()'. Basically, 'plot()' looks at the "call" component of 'fit' when constructing the Cook's distance plot, determines that the name of the formula used to fit the model is "my.formula", doesn't see "my.formula" as an argument to 'plot()' or created within 'plot, and then goes looking down the search list for "my.formula".


    Another place S+ looks for objects is in what is called the "expression frame".  One solution to this problem is to place a copy of "my.formula" in the expression frame:


    my.lm.func2 <- function(my.formula,


       assign("",, frame = 1)

       assign("my.formula", my.formula, frame = 1)

       fit <- lm(my.formula,

       old.par <- par(mfrow = c(3, 2))






    Output of a call to this function:

    > my.lm.func2(Mileage~Weight,fuel.frame)


    lm(formula = my.formula, data =


    (Intercept) Weight

    48.34935 -0.008192823



    Another discussion on the subject of frames:


    In S, objects defined inside a function are not visible to functions called by the first function. This is explained on pages 118-121 of the "blue book", "The New S Language" by Becker, Chambers and Wilks, and in the TIBCO Spotfire S+ 8.1 Programmer's Guide, in the section titled "Matching Names and Values".


    For example:

    a <- 3

    foo <- function(x)


       a <- x




    bar <- function()






    The result is 3, not 7.

    The bar() function looks for objects in:

    (1) it's own frame   (any objects already defined inside bar)

    (2) frame 1   (the "expression frame", a temporary frame in memory)

    (3) frame 0   (the "session frame", a temporary frame in memory that persists between commands but disappears when you exit S+)

    (4) permanent databases

    'bar' does not look in anywhere between frame 1 and its own frame (in the above example, foo has frame 2 and bar has frame 3.  For another example, if you call f, which calls foo, which calls bar, then f has frame 2, foo frame 3, and bar frame 4).

    In other words, if you define something inside 'foo', it is invisible to 'bar'.


    A frame is essentially a list of objects that a function has defined for its own use (but frame 0 and frame 1 are for universal use).  For example, after "a <- x", then foo's frame contains 'a' and 'x'.

    The exception is if you explicitly use:

    get(<an object name>, <the number of the frame of foo>)

    to specify where to look for the object that would otherwise be invisible.


©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center