-
Notifications
You must be signed in to change notification settings - Fork 35
Feature/159 add longitudinal employment calculations #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewbaxter439
merged 22 commits into
develop
from
feature/159-add-longitudinal-employment-calculations
Apr 14, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
54fa259
generate outline Employment statistics file
andrewbaxter439 d4f2bf5
add employmetn history filter
andrewbaxter439 fd4bc98
update to calculate all validation statistics
andrewbaxter439 e08f682
added collector arguments for employment statistics - default off
andrewbaxter439 e7fe65a
working employment stats
andrewbaxter439 ac130ca
bad test
andrewbaxter439 f884b10
add employment lag1 getters
andrewbaxter439 27aaad8
workign tests for filtering employed and unemploed
andrewbaxter439 88c2b5b
working tests for proportions in/out of employment
andrewbaxter439 b86b138
Update src/test/java/simpaths/data/filters/EmploymentHistoryFilterTes…
andrewbaxter439 e22c63c
Update src/test/java/simpaths/data/filters/EmploymentHistoryFilterTes…
andrewbaxter439 87fa2b9
add a config file to only report employment transitions statistics
andrewbaxter439 8ce401a
added a test class of person with an ID
andrewbaxter439 a321079
added a test class of Benefit Unit with id
andrewbaxter439 96d3586
Updated Person test class with seed passed to Innovation object
andrewbaxter439 fc1f9cf
Merge branch 'feature/flexible-person-bu-test-classes' into feature/1…
andrewbaxter439 52b25a1
change all persons to test person new class
andrewbaxter439 411e183
Revert "change all persons to test person new class"
andrewbaxter439 4e29271
Revert "Merge branch 'feature/flexible-person-bu-test-classes' into f…
andrewbaxter439 d5ea53a
change filter tests to parameterised tests across person array
andrewbaxter439 c7a6ccc
simpler tests
andrewbaxter439 f235d47
Apply suggestions from code review
andrewbaxter439 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # This file can be used to override defaults for multirun arguments. | ||
| # Arguments of the SimPathsMultiRun object overridden by the command-line | ||
|
|
||
| maxNumberOfRuns: 1 | ||
| executeWithGui: false | ||
| randomSeed: 606 | ||
| startYear: 2011 | ||
| endYear: 2020 | ||
| popSize: 50000 | ||
|
|
||
| # Arguments passed to the SimPathsModel | ||
| model_args: | ||
| # maxAge: 130 | ||
| # fixTimeTrend: true | ||
| # timeTrendStopsIn: 2017 | ||
| # fixRandomSeed: true | ||
| # sIndexTimeWindow: 5 | ||
| # sIndexAlpha: 2 | ||
| # sIndexDelta: 0 | ||
| # savingRate: 0 | ||
| # initialisePotentialEarningsFromDatabase: true | ||
| # useWeights: false | ||
| # useSBAMMatching: | ||
| # projectMortality: true | ||
| # alignFertility: true | ||
| # labourMarketCovid19On: false | ||
| # projectFormalChildcare: true | ||
| # donorPoolAveraging: true | ||
| # alignEmployment: false | ||
| # projectSocialCare: false | ||
| # enableIntertemporalOptimisations: true | ||
| # responsesToLowWageOffer: true | ||
| # saveImperfectTaxDBMatches: false | ||
| # useSavedBehaviour: false | ||
| # readGrid: "laptop serial" | ||
| # saveBehaviour: true | ||
| # employmentOptionsOfPrincipalWorker: 3 | ||
| # employmentOptionsOfSecondaryWorker: 3 | ||
| # responsesToEducation: true | ||
| # responsesToRetirement: false | ||
| # responsesToHealth: true | ||
| # responsesToDisability: false | ||
| # minAgeForPoorHealth: 50 | ||
| # responsesToRegion: false | ||
|
|
||
| # Arguments that alter processing of the SimPathsMultiRun object | ||
| innovation_args: | ||
| # randomSeedInnov: false | ||
| # intertemporalElasticityInnov: false | ||
| # labourSupplyElasticityInnov: true | ||
|
|
||
| collector_args: | ||
| # calculateGiniCoefficients: false | ||
| # exportToDatabase: false | ||
| # exportToCSV: true | ||
| persistStatistics: false | ||
| persistStatistics2: false | ||
| persistStatistics3: false | ||
| persistPersons: false | ||
| persistBenefitUnits: false | ||
| persistHouseholds: false | ||
| persistEmploymentStatistics: true | ||
| # dataDumpStartTime: 0L | ||
| # dataDumpTimePeriod: 1.0 |
27 changes: 27 additions & 0 deletions
27
src/main/java/simpaths/data/filters/EmploymentHistoryFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package simpaths.data.filters; | ||
|
|
||
| import microsim.statistics.ICollectionFilter; | ||
| import simpaths.model.Person; | ||
| import simpaths.model.enums.Gender; | ||
| import simpaths.model.enums.Les_c4; | ||
|
|
||
| public class EmploymentHistoryFilter implements ICollectionFilter { | ||
|
|
||
| private Les_c4 employmentLag1; | ||
|
|
||
| public EmploymentHistoryFilter(Les_c4 employmentLag1) { | ||
| super(); | ||
| this.employmentLag1 = employmentLag1; | ||
|
|
||
| } | ||
|
|
||
| public boolean isFiltered(Object object) { | ||
|
|
||
| if (object instanceof Person){ | ||
| Person person = (Person) object; | ||
| return (person.getLes_c4_lag1().equals(employmentLag1)); | ||
| } | ||
| else throw new IllegalArgumentException("Argument passed to EmploymentHistoryFilter must be of object type Person"); | ||
| } | ||
|
|
||
| } |
70 changes: 70 additions & 0 deletions
70
src/main/java/simpaths/data/statistics/EmploymentStatistics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package simpaths.data.statistics; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Entity; | ||
|
|
||
| import microsim.data.db.PanelEntityKey; | ||
| import microsim.statistics.CrossSection; | ||
| import microsim.statistics.IDoubleSource; | ||
| import microsim.statistics.functions.MeanArrayFunction; | ||
| import simpaths.data.filters.EmploymentHistoryFilter; | ||
| import simpaths.model.SimPathsModel; | ||
| import simpaths.model.enums.Les_c4; | ||
| import simpaths.model.Person; | ||
|
|
||
| @Entity | ||
| public class EmploymentStatistics { | ||
|
|
||
| @Id | ||
| private PanelEntityKey key = new PanelEntityKey(1L); | ||
|
|
||
| @Column(name= "EmpToNotEmp") | ||
| private double EmpToNotEmp; // Proportion of employed people becoming unemployed | ||
|
|
||
| @Column(name= "NotEmpToEmp") | ||
| private double NotEmpToEmp; // Proportion of unemployed people becoming employed | ||
|
|
||
|
|
||
| public double getEmpToNotEmp() { | ||
| return EmpToNotEmp; | ||
| } | ||
|
|
||
| public void setEmpToNotEmp(double empToNotEmp) { | ||
| EmpToNotEmp = empToNotEmp; | ||
| } | ||
|
|
||
| public double getNotEmpToEmp() { | ||
| return NotEmpToEmp; | ||
| } | ||
|
|
||
| public void setNotEmpToEmp(double notEmpToEmp) { | ||
| NotEmpToEmp = notEmpToEmp; | ||
| } | ||
|
|
||
| public void update(SimPathsModel model) { | ||
|
|
||
| EmploymentHistoryFilter employmentHistoryEmployed = new EmploymentHistoryFilter(Les_c4.EmployedOrSelfEmployed); | ||
| EmploymentHistoryFilter employmentHistoryUnemployed = new EmploymentHistoryFilter(Les_c4.NotEmployed); | ||
|
|
||
|
|
||
| // Entering employment transition rate | ||
| CrossSection.Integer personsNotEmpToEmp = new CrossSection.Integer(model.getPersons(), Person.class, "getEmployed", true); | ||
| personsNotEmpToEmp.setFilter(employmentHistoryUnemployed); | ||
| // Entering not employed transition rate | ||
| CrossSection.Integer personsEmpToNotEmp = new CrossSection.Integer(model.getPersons(), Person.class, "getNonwork", true); | ||
| personsEmpToNotEmp.setFilter(employmentHistoryEmployed); | ||
|
|
||
|
|
||
| MeanArrayFunction isNotEmpToEmp = new MeanArrayFunction(personsNotEmpToEmp); | ||
| isNotEmpToEmp.applyFunction(); | ||
| setNotEmpToEmp(isNotEmpToEmp.getDoubleValue(IDoubleSource.Variables.Default)); | ||
|
|
||
| MeanArrayFunction isEmpToNotEmp = new MeanArrayFunction(personsEmpToNotEmp); | ||
| isEmpToNotEmp.applyFunction(); | ||
| setEmpToNotEmp(isEmpToNotEmp.getDoubleValue(IDoubleSource.Variables.Default)); | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/simpaths/data/filters/EmploymentHistoryFilterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package simpaths.data.filters; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import simpaths.model.Person; | ||
| import simpaths.model.enums.Les_c4; | ||
|
|
||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| @DisplayName("Test filtering by employment history") | ||
| class EmploymentHistoryFilterTest { | ||
|
|
||
| private static Person createTestPerson( | ||
| Les_c4 les_c4_lag1 | ||
| ) { | ||
| Person testPerson = new Person(true); | ||
| testPerson.setLes_c4_lag1(les_c4_lag1); | ||
|
|
||
| return testPerson; | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Employed filter only returns true for employed or self-employed persons") | ||
| void employedOrSelfEmployed() { | ||
| EmploymentHistoryFilter filter = new EmploymentHistoryFilter(Les_c4.EmployedOrSelfEmployed); | ||
| assertTrue(filter.isFiltered(createTestPerson(Les_c4.EmployedOrSelfEmployed))); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.NotEmployed))); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.Student))); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.Retired))); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Unemployed filter only returns true for unemployed persons") | ||
| void unEmployed() { | ||
| EmploymentHistoryFilter filter = new EmploymentHistoryFilter(Les_c4.NotEmployed); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.EmployedOrSelfEmployed))); | ||
| assertTrue(filter.isFiltered(createTestPerson(Les_c4.NotEmployed))); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.Student))); | ||
| assertFalse(filter.isFiltered(createTestPerson(Les_c4.Retired))); | ||
| } | ||
|
|
||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.