Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Assistance required for writing loops

    Hello everyone!

    I require assistance in writing the loops.

    My data consists of the following in respect of US states.
    State name, year, month of the year, product description code, and monthly tax rate (dependent variable).
    There are:
    • 50 states
    • 6 years,
    • 12 months for each of the year
    • 30 products
    I want to calculate the spatial lag of the monthly tax rate using spmat command (contiguity and inverse distance).
    I can do the procedure from taking a shapefile and calculating the Spatial weighting Matrix by following Drukker et al. 2013


    I want to
    1. Keep the data in following example format:
    year month state product code rate
    2000 1 Alabama 101 20
    2000 1 Arizona 101 12
    2000 1 Arkansas 101 25
    1. Calculate the Spatial weighting Matrix and then spatial lag for the monthly tax rate.
    2. Write a loop (foreach) that will repeat the procedure for all products and months-years.
    Thank you!
    Last edited by Chinmay Korgaonkar; 08 Jan 2023, 11:26.

  • #2
    Hi Chinmay,

    I would suggest you write a loop to break your main data into many sub-datasets by year-month and product.

    Then you can calculate the regular weighting matrix for each sub-dataset and merge them in the end.

    Comment


    • #3
      Thank you. I will try this method.

      Comment

      Working...
      X