cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
dale_lehman
Level VII

Time Series Analysis - scripters needed

I am trying to do an ARIMA (1,1,0) analysis on time series data - sample attached.  My table has 450 cities, only 2 are in the sample file.  I want to do the same analysis for each city.  In many JMP platforms, I can hold down the control key and ask for the analysis and it will be done for all the cities in the By box.  However, for setting the ARIMA values, it give me the dialog for each city (450 of them!).  I suspect there is a way to script this so that I only need to specify ARIMA (1,1,0) once and have it applied to each city - but I don't know how to do that.  Can someone help?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Time Series Analysis - scripters needed

Here is a script that I believe will give you what you want

Names Default To Here( 1 );
dt = Current Data Table();

ts = Time Series(invisible,
	X( :month ),
	Y( :indexed prices ),
	Forecast Periods( 24 ),
	By( :RegionName of Zillow Data )
);

// Start final table
dtFinal = New Table( "Final", New Column( "RegionName of Zillow Data", character ) );

// Loop across output creating ARIMA and the Save Columns
For( i = 1, i <= N Items( ts ), i++,
	objt = ts[i] << arima( 1, 1, 0 );
	dtTemp = objt << save columns;
	
	// Add the By Group name to the data table
	RZD = Word( 2, Report( ts[i] )[Outline Box( 1 )] << get title, "=" );
	dtTemp << New Column( "RegionName of Zillow Data", character, set each value( RZD ) );

	// Add the new table to the Final data table
	dtFinal << concatenate( dtTemp, Append to first table( 1 ) );
	Close( dtTemp, nosave );
);
Jim

View solution in original post

6 REPLIES 6
ngambles
Level III

Re: Time Series Analysis - scripters needed

The following script will generate an ARIMA(1,1,0) model for "indexed prices" vs "month" for each unique value in "RegionName of Zillow Data." 

 

Time Series(
	X( :month ),
	Y( :indexed prices ),
	ARIMA( 1, 1, 0 ),
	Forecast Periods( 24 ),
	By( :RegionName of Zillow Data)
);
dale_lehman
Level VII

Re: Time Series Analysis - scripters needed

Thank you - this does what I asked for, but I guess I need one more thing.  I want to save the predictions from these models but the two options - save Prediction Formula or Save Columns both create a new data table for each region (450 of them).  I would like the predictions (with or without standard errors and confidence intervals) to appear in the same data table, but the prediction column should contain the predictions for each of the By group regions.  In other words, one data table, not 450 of them (it can either be one new data table or just columns added to the existing table).

txnelson
Super User

Re: Time Series Analysis - scripters needed

Does this give you what you want?

New Window( "Subset of Comparison data - Time Series of prices",
	V List Box(
		Time Series(
			X( :month ),
			Y( :prices ),
			ARIMA( 1, 1, 0 ),
			Where(
				:RegionName of Zillow Data == "Los Angeles-Long Beach-Anaheim, CA"
			)
		),
		Time Series(
			X( :month ),
			Y( :prices ),
			ARIMA( 1, 1, 0 ),
			by(:RegionName of Zillow Data),
			SendToReport(
				Dispatch(
					{"Model Comparison"},
					"",
					ScrollBox,
					{Background Color( 117 )}
				)
			)
		)
	)
);
Jim
dale_lehman
Level VII

Re: Time Series Analysis - scripters needed

Same issue - thanks, this does what I asked for.  But I need one more thing - I want to save the predictions from the model all in one table.  If I control-click on the save options, I get 450 tables, one for each Region Name.  Is there a way to get one table with the prediction column linked to each value in Region Name?

txnelson
Super User

Re: Time Series Analysis - scripters needed

Here is a script that I believe will give you what you want

Names Default To Here( 1 );
dt = Current Data Table();

ts = Time Series(invisible,
	X( :month ),
	Y( :indexed prices ),
	Forecast Periods( 24 ),
	By( :RegionName of Zillow Data )
);

// Start final table
dtFinal = New Table( "Final", New Column( "RegionName of Zillow Data", character ) );

// Loop across output creating ARIMA and the Save Columns
For( i = 1, i <= N Items( ts ), i++,
	objt = ts[i] << arima( 1, 1, 0 );
	dtTemp = objt << save columns;
	
	// Add the By Group name to the data table
	RZD = Word( 2, Report( ts[i] )[Outline Box( 1 )] << get title, "=" );
	dtTemp << New Column( "RegionName of Zillow Data", character, set each value( RZD ) );

	// Add the new table to the Final data table
	dtFinal << concatenate( dtTemp, Append to first table( 1 ) );
	Close( dtTemp, nosave );
);
Jim
dale_lehman
Level VII

Re: Time Series Analysis - scripters needed

jim, you've done it again!  Perfect!