Products | Versions |
---|---|
Spotfire Analyst | All |
Spotfire Enterprise Runtime for R | All |
Least Squares ![]() | Major Axis ![]() | Reduced Major Axis ![]() |
Step 1. Create the data function:
Create the data function which takes the data table and performs the regression analysis.
This can be created here:
#--------------------------------------- #Install and load the user-contributed "lmodel2" package from the open-source R community's CRAN repository: install.packages( "lmodel2", repos = "http://cran.us.r-project.org" ) library( lmodel2 ) #Create regression model, from input data table "inputdf" suppressMessages( RMA_model <- lmodel2( Y~X, data = inputdf ) ) #Extract the SMA slope and intercept #Available methods: # OLS = 1 #Matches "Lines & Curves > Straight Line Fit" # MA = 2 # SMA = 3 method <- 3 intercept <- data.frame( RMA_model[3] )[method, 2] slope <- data.frame( RMA_model[3] )[method, 3] #Output as data frame, for returning to Spotfire as a data table output <- data.frame( intercept, slope ) #---------------------------------------
#--------------------------------------- #Install and load the user-contributed "lmodel2" package from the open-source R community's CRAN repository: install.packages( "lmodel2", repos = "http://cran.us.r-project.org" ) library( lmodel2 ) #Create regression model, from input data table "inputdf" suppressMessages( RMA_model <- lmodel2( Y~X, data = inputdf ) ) #Extract the SMA slope and intercept #Available methods: # OLS = 1 #Matches "Lines & Curves > Straight Line Fit" # MA = 2 # SMA = 3 method <- 3 intercept <- data.frame( RMA_model[3] )[method, 2] slope <- data.frame( RMA_model[3] )[method, 3] #Output as data frame, for returning to Spotfire as a data table output <- data.frame( intercept, slope ) #---------------------------------------
Requirements:
Since this uses a data function, it requires a statistics engine to work. TERR is included in the Professional/Analyst/Desktop Client starting with version 5.0. There are no additional requirements for this to work in those clients. For this to work on Web Player, configure Spotfire to point to a TIBCO Spotfire Statistics Services (TSSS) server instance. This TSSS URL must be configured according to the "TIBCO Spotfire Statistics Services Installation and Administration Manual".
Note: The user-contributed "lmodel2" package from the open-source R community's CRAN repository is not a TIBCO product.